Reputation: 1496
Just a quick question on VBA Arrays...
What happens if I use the ReDim Preserve
statement and I resize an Array by decreasing the Upper index number. If myArray(5) ="Shmoo"
what if I do that:
ReDim Preserve myArray(2)
Can it be done since the Preserve
must not loose the data that are tied to each index number in the array and index number 5 in the array has the String value "Smoo" ?
Upvotes: 1
Views: 114
Reputation: 5385
The data in myArray(3)
, myArray(4)
and myArray(5)
will be lost. Preserve
only keeps the data that fits within the new size specified with the ReDim
statement.
From the Excel VBA help file:
If you make an array smaller than it was, data in the eliminated elements will be lost.
Upvotes: 3