Can't ReDim, Erase, or assign to Variant that contains array whose element is With object

This error has the following causes and solutions:

  • You've attempted to ReDim, Erase, or assign to a Variant a variable whose element is a With object. For example, the following code produces this error:
Type Test
   Name as Integer
End Type

Sub Main()
   Dim c(0) As Test
   Dim e e = c
   With e(0)
      ReDim e(1)
   End With
End Sub

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.