It is also "Good Policy" to define the array with Dim first.
Either
Dim MyArray ' Variant to contain array
Or
Dim MyArray() ' Array of Variants
ReDim MyArray(X) ' Actually allocate it.
....
ReDim Preserve MyArray(X+10) ' Resize saving previous
ReDim Preserve MyArray(X-10) ' Resize dropping 10
Arrays are 0 based so if you want 10 items and you are storing in element 0 then allocate with Ybound of 9.
(9) 0 through 9.
Dim X ' Count of items
If X > 0 then
ReDim Myarray(X-1)
End if
I usually start storing in element 1 and leave element 0 empty so I use X rather than X-1.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.