Attempt to access an uninitialized dynamic array

Either of the following situations could have produced this error:

  • You tried to assign an uninitialized dynamic array to a Variant:
    Dim anArray() As Integer
    Dim varV As Variant
    varV = anArray			' Illegal.

    Use the ReDim statement to assign bounds to the array before assigning the array to the Variant.

  • You tried to pass an uninitialized dynamic array to the LBound or UBound function:
    Dim anArray() As Integer
    LB% = LBound(anArray)		' Illegal.

    Use the ReDim statement to assign bounds to the array before calling the LBound or UBound function.