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

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

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