The RegisterCustomFunction method registers an IFunction object with the workbook to be used when calculating custom formulas.

 public void RegisterCustomFunction(string customFunctionName, IFunction customFunction)
 Public Sub RegisterCustomFunction(customFunctionName As String, customFunction As IFunction)
//Create an ExcelApplication object
ExcelApplication xla = new ExcelApplication();

//Open a workbook containing formulas
Workbook wb = xla.Open("FormulasWorkbook.xlsx); 

// Create an instance of the custom function implementation
IFunction myCustomFunction = new MyCustomFunction();
//Register the custom function
wb.RegisterCustomFunction("MyCustomFunction", myCustomFunction);
'Create an ExcelApplication object
Dim xla As New ExcelApplication
 
'Open a workbook containing formulas
Dim wb As Workbook = xla.Open("formulasWorkbook.xlsx")
 
'Create an instance of the custom function implementation
Dim myCustomFunction As IFunction = new MyCustomFunction()

'Register the custom function
wb.RegisterCustomFunction("MyCustomFunction", myCustomFunction)

 

 

 

If the custom function has already been registered with the workbook.