Hi everyone,
How can I make a dynamic array public?
I have to Dim it so it stays valid only inside the sub.
The below code does not work
Error I get is 'MyVar(x) = Subscript out of range'
How can I make a dynamic array public?
I have to Dim it so it stays valid only inside the sub.
The below code does not work
Code:
Public MyVar()
Sub test1()
Dim MyVar()
ReDim MyVar(1 To 4)
For x = 1 To 4
MyVar(x) = "ffffff"
Next x
End Sub
Sub test2()
For x = 1 To 4
Range("A" & x) = MyVar(x)
Next x
End Sub
Error I get is 'MyVar(x) = Subscript out of range'