I have a function that fills a certain array with cell values depending on which OptionButton is selected. How would I reference those same arrays in a seperate function which would feed those values back into the cells? Here is my (working) code so far.
Private Sub CommandButton1_Click()
Dim wave1Array(0 To 30) As String
Dim wave2Array(0 To 30) As String
Dim wave3Array(0 To 30) As String
Dim wave4Array(0 To 30) As String
Dim wave5Array(0 To 30) As String
Dim rng As Range
Dim cell As Range
Dim counter As Long
Set rng = Range("B2", "AF2")
counter = 0
If OptionButton6.Value = True Then
For Each cell In rng
wave1Array(counter) = cell.Value
counter = counter + 1
Next cell
ElseIf OptionButton7.Value = True Then
For Each cell In rng
wave2Array(counter) = cell.Value
counter = counter + 1
Next cell
ElseIf OptionButton8.Value = True Then
For Each cell In rng
wave3Array(counter) = cell.Value
counter = counter + 1
Next cell
ElseIf OptionButton9.Value = True Then
For Each cell In rng
wave4Array(counter) = cell.Value
counter = counter + 1
Next cell
ElseIf OptionButton10.Value = True Then
For Each cell In rng
wave5Array(counter) = cell.Value
counter = counter + 1
Next cell
End If
End Sub
Dim wave1Array(0 To 30) As String, etc) out of yourSub()and have them in the module then they would be accessible from any sub within that module... This could also be a bad thing, though, since you should check to make sure they have the values you expect at different times....