Table of contents
TOC
Collapse the table of content
Expand the table of content

Array already dimensioned

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

A static array can only be dimensioned once. This error has the following causes and solutions:

  • You attempted to change the dimensions of a static array with a ReDim statement; only dynamic arrays can be redimensioned. Either remove the redimensioning or use a dynamic array. To define a dynamic array, use a Dim, Public, Private, or Static statement with empty parentheses. For example: Dim MyArray() In aprocedure, you can define a dynamic array with the ReDim or Static statement using avariable for the number of elements:
Dim MyArray() 
ReDim MyArray(n) 
 In a[procedure](vbe-glossary.md), you can define a dynamic array with the  **ReDim** or **Static** statement using a[variable](vbe-glossary.md) for the number of elements: `ReDim MyArray(n)`
  • An Option Base statement occurs after array dimensions are set. Make sure any Option Base statement precedes all array declarations.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

© 2018 Microsoft