I want to write a Excel function like this. It is an extension of the Dec2Bin function
Public Function Dec2BinEx(x As Long)
Dec2BinEx = dec2bin(x) + 10
End Function
But I am getting an error when trying to use it. How do I call a excel function inside the visual basic editor
In general, you call Excel functions with
Application.WorksheetFunction.SomeFunctionName. However,Dec2Binis special, as it is an Add-In function, and not a pure Excel function. Hence,Application.WorksheetFunctiondoes not work here. Instead, you have to make the functions of the add-in available to your code. To do so, follow these stepsIn Excel, menu Tools/Add-Ins, make
sure that the add-in
Analysisis imported.ToolPak - VBA
Then, set a reference to this add-in
in your code: in the VBA editor, menu
Tools/References, add a reference to
atpvbaen.xls.Then, your original code, as posted in your quesiton should work just fine.