ReDim Instruction

Syntax

ReDim [Preserve] vardeclaration [As type][, ...]

Group

Declaration

Description

Redimensions a dynamic arrayvar or user defined type array element. Use Preserve to keep the array values. Otherwise, the array values are reset. When using preserve, only the last index of the array can change, but the number of indexes cannot. A one-dimensional array cannot be redimensioned as a two-dimensional array.

Example


Sub Main
    Dim X()
    ReDim X(3)
    Debug.Print UBound(X) ' 3
    ReDim X(200)
    Debug.Print UBound(X) ' 200
End Sub

See also

Dim, Option Base, Private, Public, Static