I apologize if this has been answered elsewhere...I searched for quite a while and found nothing specific for what I am hoping to do.
I am trying to populate multiple 1D arrays with a nested For Next loop. I have tried to use a string to build the array name (ie. arr1, arr2, etc.) and reference the string in place of the array name for the LBound and UBound. I get an error stating "Expected array". Is there a way to do this? Below is my code.
Any help would be greatly appreciated.
Thanks,
duggie33
I am trying to populate multiple 1D arrays with a nested For Next loop. I have tried to use a string to build the array name (ie. arr1, arr2, etc.) and reference the string in place of the array name for the LBound and UBound. I get an error stating "Expected array". Is there a way to do this? Below is my code.
Code:
Sub RedimTrials2()
Dim arr1() As Variant
Dim arr2() As Variant
Dim arr3() As Variant
Dim arr4() As Variant
Dim str_ArrayName As String
Dim i As Integer
Dim j As Integer
i = 3
ReDim arr1(1 To i)
ReDim arr2(1 To i)
ReDim arr3(1 To i)
ReDim arr4(1 To i)
For j = 1 To 4
str_ArrayName = "arr" & j
For i = LBound(str_ArrayName, 1) To UBound(str_ArrayName, 1)
str_ArrayName(i, j) = Sheet1.Range("A1").Offset(i - 1, j - 1).Value
Next i
Next j
End Sub
Any help would be greatly appreciated.
Thanks,
duggie33