ReDim Preserve


Preserving Values

ReDim will re-initialize the array and destroy any data in it unless you use the Preserve keyword.
Preserve copies the elements from the old array to the new array.
It is possible to resize an array without losing the existing values by using the Preserve keyword.
When you use Preserve you can only change the size of the upper bound (not the lower bound).

This is an expensive operation and should be used sparingly.


Partial Clearing

You can use the ReDim Preserve statement to keep only some values.


Never In A Loop

The ReDim Preserve statement creates a new array - and the elements of the old array get copied into the new one.
If you are running on low memory this can cause virtual memory to be used which slows down performance.


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext