User-defined type may not be passed ByVal
User-defined types can only be passed by reference (the default), not by value. The error may not be reported until the call is made. This error has the following cause and solution:
You placed a ByVal keyword in the definition of a parameter that represented a user-defined type.
Remove the ByVal keyword. To keep changes from being propagated back to the caller, Dim a temporary variable of the type and pass the temporary variable into the procedure.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
See also
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.