UDF with array of optional parameters

Skip to first unread message

Jordan McFarland

Dec 14, 2021, 9:34:33 PM12/14/21
to Excel-DNA
Hi Govert - Is there a way to have a method signature with standard required parameters along with an optional array of parameters?

I was thinking something like this:

But I get the error:

Theoretically I could use one object array parameter for everything; however, I like spelling out standard parameters for intellisense and all it's glory :)

Thanks in advance!

Govert van Drimmelen

Dec 15, 2021, 9:57:18 AM12/15/21
to Excel-DNA
Excel-DNA is now registered on GitHub Sponsors.
Your monthly contribution helps the project thrive.

Hi Jordan,

I think this issue (and the fixed sequence in the registration rewrite) has all the bits you needs to set up the registration for such functions

In your code, the AllowReference=true does nothing (since the parameter type is not object) but it looks confusing.
AllowReference=true on an object parameter means that is the users calls the function with a reference, the argument will be an ExcelReference object.
Otherwise (and in your case with string parameters) Excel passes the value at the reference into the function, which is what you normally want.


Jordan McFarland

Dec 15, 2021, 10:54:57 AM12/15/21
to Excel-DNA
Hi Govert your suggestion worked:

I added  ProcessParamsRegistrations.


Much thanks!
Reply all
Reply to author
0 new messages