Are Named Arguments not supported in VBA?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,543
Office Version
  1. 365
Platform
  1. Windows
I came across this page that explains Named Arguments.


But I can't get it to work. Here's the little test function I wrote:

VBA Code:
Function TestArgs(p1, p2, p3)
Debug.Print Time & " p1 = '" & p1 & "', p2 = '" & p2 & "', p3 = '" & p3 & "'"
End Function

I tried calling it like this =testargs(p1:=1, p2:=2, p3:=3), but Excel takes p1, p2, & p3 to be cell addresses and it gets an error. I tried renaming the parameters to something that cannot be a cell address, but I got the same error.

Is this just a VB.Net feature?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I think I found the answer. Apparently, this feature only works within VBA. If I call that test function from the Immediate window, it works:

1677397556891.png


(sigh)
 
Upvote 0

Forum statistics

Threads
1,216,089
Messages
6,128,760
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top