Hi!
I found quite a few posts about this problem, but none of the answers was any use to me...
I need to redimension a 2 dimensional array in a Sub. I deleted all the code that is not of interest:
Option Explicit
Dim Gear() As String 'I also tried "Private" and without the "As String", or givin a specific dimension right here.
Sub Workbook_Open()
Call setup_arrays
If Gear(i, 1) = "son-and so" Then
[blablabla]
End If
End Sub
Sub setup_arrays()
ReDim Gear(8, 2) As String ' I also tried "Redim Preserve"
Gear(1, 1) = "a"
Gear(2, 1) = "b"
[...]
Gear(8, 1) = "c"
Do While temp = "6" ' this is of course true, when testing...
MsgBox "the code works fine until here!!!"
ReDim Preserve Gear(UBound(Gear) + 1, 2) As String ' this code causes the error! All I want is to increase the first dimension of the array by 1, while the second dimension remains untouched.
Gear(UBound(Gear), 1) = "d"
Loop
[...]
End Sub
Can somebody tell my why I receive the Run-time error '9': Subscript out of range"?.... or even better, tell me how to avoid it?
Thanks in advance!
Broesel
Bookmarks