I'm tearing my hair out over what I am sure is a simple problem.
I want to read a series of Excel ranges into VBA arrays. I set up a simple test to read a 3C x 5R range into an array.
Sub testforms()
Dim GrowthArray As Variant
GrowthArray = Worksheets("Variables").Range("SalesGrowth")
For i = 1 To 3
For j = 1 To 5
MsgBox GrowthArray(j, i) 'to check that it worked
Next j
Next i
End Sub
This all seemed good so I moved on to what I thought was a simpler array with just 1 column x 5 rows
Sub testforms2()
Dim BusinessStreams As Variant
BusinessStreams = Worksheets("Variables").Range("BusStreams")
For i = 1 To 5
MsgBox BusinessStreams(i)
Next i
End Sub
This code seems to match the earlier version but when I run it I get a 'subscript out of range' error.
HELP!
I want to read a series of Excel ranges into VBA arrays. I set up a simple test to read a 3C x 5R range into an array.
Sub testforms()
Dim GrowthArray As Variant
GrowthArray = Worksheets("Variables").Range("SalesGrowth")
For i = 1 To 3
For j = 1 To 5
MsgBox GrowthArray(j, i) 'to check that it worked
Next j
Next i
End Sub
This all seemed good so I moved on to what I thought was a simpler array with just 1 column x 5 rows
Sub testforms2()
Dim BusinessStreams As Variant
BusinessStreams = Worksheets("Variables").Range("BusStreams")
For i = 1 To 5
MsgBox BusinessStreams(i)
Next i
End Sub
This code seems to match the earlier version but when I run it I get a 'subscript out of range' error.
HELP!