The following minimal example crashes until the Erase statement is commented out. Why?
(I can't find this documented.)
Sub Test()
Dim a1() As Integer
ReDim a1(0 To 2)
Erase a1
Debug.Print a1(1) ' Subscript out of range (Run-time error '9')
Debug.Print LBound(a1) ' Subscript out of range (Run-time error '9')
Debug.Print UBound(a1) ' Subscript out of range (Run-time error '9')
End Sub
Should I replace the Erase with For i = LBound(a1) to UBound(a1): a1(i) = 0: Next i?