I think what still wasn't answered is why
1. MySub(MyArg)
works just fine, but
2. MyOtherSub(MyArg1, MyArg2)
does not
This blog entry explains it well.
Essentially, you can pass an argument which would normally be byref as byval:
Call MySub(Arg1, (Arg2)) 'Arg1 is passed byref, Arg2 is passed byval
Code #1. works because VBA thinks you are passing one argument byVal so it doesnt count as parentheses being used in a Sub
call without the Call
keyword. As mentioned in other answers, no parentheses are allowed in a Sub
call without the Call
keyword.
The Call
keyword requires Params in parentheses. So with the Call
keyword Call MySub(MyArg)
would actually pass MyArg
byRef because the parentheses are used as the enclosure for arguments.
Code #2 does not work because there is no valid way to justify the parentheses in the syntax (it is only allowed with the Call
keyword.