What are ReDim Statements in VBA?

ReDim statement is used to declare dynamic-array variables and allocate or reallocate storage space.

Syntax

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

Parameter Description

  • Preserve − An optional parameter used to preserve the data in an existing array when you change the size of the last dimension.
  • Varname − A required parameter, which denotes the name of the variable, which should follow the standard variable naming conventions.
  • Subscripts − A required parameter, which indicates the size of the array.