I have a compilation error in Excel VBA that I do not understand ...
I have a method like this:
Public Sub SomeMethod(ByRef argument As SomeClass) ... <- 'argument' must be called ByRef because I have to modify it End Sub
If I define a variable like:
Dim var As SomeClass
No problem, I can call:
SomeMethod var
and it works.
BUT, if I define the Variant variable as:
Dim var as Variant Set var = New SomeClass
This does not work.
If I call:
SomeMethod var
VB pops up a message: 'ByRef argument type mismatch'
If I call:
SomeMethod (var)
it is "compiled", but var is then passed to ByVar, and it gave me a runtime error: "The object does not support this property or method"
So I just want to tell VBA that the Variant "var" variable is actually a "SomeClass" object (in the debugger, says VBA), but I don't know how to do this ...
Can anyone help me out?
source share