I'm creating an Addin for Excel using VB.NET and the Excel-DNA Library. Functions created on my Addin project works perfectly when called as formulas on Worksheets. But I would also like them to be available when writing VBA code.
So, let's say I have a function SumCalculation created on Excel-DNA as below:
<ExcelFunction(Category:="Calculations", Description:="Sum values", Name:="")>
Public Function SumCalculation(<ExcelArgument("First Value to sum")> Value1 As Double,
<ExcelArgument("Second Value to sum")> Value2 As Double) As Double
Return Value1 + Value2
End Function
When the XLL is generated and loaded on Excel, it can be called on VBA like this:
Result = Application.Run("SumCalculation", 1, 1)
But is there some way to call it directly as below?
Result = SumCalculation(1, 1)