편집

다음을 통해 공유


Array already dimensioned

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).

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.