Are Named Arguments not supported in VBA?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,687
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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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