Rasmus Andersen
Rasmus Andersen

Reputation: 13

Vba function evaluated by named parameters

Is it possible to invoke a function by specifying what the named parameters should be?

So for example if you have

Public function tmp(optional Byref a as integer=2, optional Byref b as integer=10)

    Tmp=a*b

End function 

I want to use the above by tmp(b=5). Hope someone can help.

Upvotes: 1

Views: 868

Answers (1)

T.M.
T.M.

Reputation: 9948

If I understand your question correctly, you want to pass only Argument b:

Debug.Print tmp(, 5)     ' results in 2 * 5 = 10

or simply as mentioned in comment by @Guest

Debug.Print tmp(b:=5)

Upvotes: 1

Related Questions