In general, you call Excel functions with Application.WorksheetFunction.SomeFunctionName
. However, Dec2Bin
is special, as it is an Add-In function, and not a pure Excel function. Hence, Application.WorksheetFunction
does not work here. Instead, you have to make the functions of the add-in available to your code. To do so, follow these steps
In Excel, menu Tools/Add-Ins, make
sure that the add-in Analysis
ToolPak - VBA
is imported.
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.