This is probably trivial but I couldn't find an answer via Google.
In Visual Basic, is it possible to save an array to a variable and then restore that array to its previous self by setting it equal to that variable?
Example:
Dim SomeArray(20) As Integer
X = SomeArray
{Do stuff to the SomeArray}
SomeArray = X
I've tried this by using a variable X defined as a Variant, but that gives a compile error. Any suggestions?
EDIT
Thank you everyone for trying to help me out. I've posted my test VBA code below. I get a compile error already at the statement "X = SomeArray". I hope one of you can tell me where my error lies. Here's the code:
Dim SomeArray(), X() As Integer
Sub Macro1()
ReDim SomeArray(1 To 20)
X = SomeArray
For i = 1 To 20
SomeArray(i) = i
Next i
SomeArray = X
For i = 1 To 20
MsgBox "SomeArray(" & i & ") = " & SomeArray(i)
Next i
End Sub