Array already dimensioned

This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.

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 a procedure, you can define a dynamic array with the ReDim or Static statement using a variable for the number of elements:

    Dim MyArray() 
    
    ReDim MyArray(n) 
    

    In a procedure, you can define a dynamic array with the ReDim or Static statement using a variable 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).