ParamArray must be declared as an array of Variant

Each argument to a ParamArray parameter can be of a different data type. Therefore, the parameter itself must be declared as an array of Variant type. You can also supply any number of arguments to a ParamArray. When the call is made, each argument supplied in the call becomes a corresponding element of the Variant array. For example:

Sub MySub(ParamArray VarArg()) 
    . . . 
End Sub 
Call MySub ("First arg", 2, 3.54) 

This error has the following causes and solutions:

  • In the definition of the procedure, the ParamArray parameter is defined as an array of a type other than Variant.

    Redeclare the parameter type as an array of Variant elements.

  • No data type was specified for the ParamArray parameter, but the procedure definition is within the scope of a Deftype statement, so the parameter is implicitly declared as having a type other than Variant. Use an explicit As Variant clause in the specification of the ParamArray parameter.

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.