Posts

Showing posts with the label Excel

ExcelDNA: Parameter Limit for Excel Functions Using a Variable Parameter Array (params and ParamArray)

Image
  Found out something interesting recently when trying to build a custom Excel function with a lot (!) of parameters...  Implementing a custom Excel function using ExcelDNA is fairly straight forward.  However, when trying to use a parameter array as a parameter, you must complete some prerequisites. First, you must include a reference to ExcelDna.Registration, register the parameter array, and register the rest of the functions.  This can be placed anywhere in code assuming it's run once at start up (either bound to some Excel AutoOpen event or your application's main class constructor, for instance) ExcelRegistration.GetExcelFunctions().ProcessParamsRegistrations().RegisterFunctions() ; Second, you must include the decorator IsMacroType:=True for it to be picked up by Excel: <ExcelFunction(Name:="TestFunction", Description:="Custom Excel Function", IsThreadSafe:=False, IsMacroType:=True)> Public Shared Function TestFunction( ParamArray pa...