Is there an "append" operator or function in VBA for appending one array to another?
Thanks in advance,
Mike
Printable View
Is there an "append" operator or function in VBA for appending one array to another?
Thanks in advance,
Mike
I am not familiar with Mac per se, but not that I know of.
You can redeclare the dimensions of an array to include the dimensions of the other..
Say you have:
[VBA]
Dim myArray()
Dim lngCount as Long
lngCount = range("A1")
ReDim myArray(1 to lngCount)
[/VBA]
Then you populate the redim'd array with potentially another array if needed
[VBA]
For x = 1 to UBound(MyArray)
MyArray(x) = 'something
Next x
[/VBA]
Hi Mike,
Short answer is no, not directly. In addition to XLGibbs post on ReDim, I'd add that you'll need to use the optional keyword "Preserve" in order to get the existing elements of your array saved during the ReDim process, otherwise, they'll get blown away.
to re-dimension the array A to 10 elements, saving the existing values.Code:ReDim Preserve A(10)
Ed