ReDim

This statement is used at procedure level to declare dynamic-array variables and to allocate or reallocate storage space.

Syntax

ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .

Parameters

varname
Name of the variable; follows standard variable naming conventions.
subscripts
Dimensions of an array variable; up to 60 multiple dimensions can be declared. The subscripts parameter uses the following syntax:
upper [, upper] . . .

The lower bound of an array is always 0.

Remarks

The ReDim statement is used to size or resize a dynamic array that has already been formally declared using a Private, Public, or Dim statement with empty parentheses; that is, without dimension subscripts.

If you use the Preserve keyword, you can resize only the last array dimension, and you cannot change the number of dimensions. If you make an array smaller than it was originally, data in the eliminated elements is lost.