Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make UDF that gives a description like the native Excel functions have when user clicks the Fx button?

Tags:

excel

vba

If I type =vlookup( (or any other native Excel function) in the formula bar and then click the little Fx button to the left of the formula I get a Function Arguments prompt with all the available arguments. In that prompt, below the functional arguments, is a one or two sentence description of the function and of each argument as you move your cursor from each argument's input box.

When I type in the name of my UDF and click the Fx I get an input box for all of my arguments but that is it. Is there a way I can add those same helpful type of descriptions that native Excel functions have?

like image 478
Dean MacGregor Avatar asked Feb 06 '13 14:02

Dean MacGregor


People also ask

How do I add a description to a User Defined Function in Excel?

Steps to Add a Description to a UDFLook to the pane on the right of the window and you should now see your UDF: If you do not see the UDF in the right pane, click through the items in the left pane until it appears. In the window that opens, type the description that you want in the Description box and then hit OK.

Can we create our own user defined functions in Excel?

To add a new function, position your insertion point after the End Function statement that terminates the last function in the Code window, and begin typing. You can create as many functions as you need in this manner, and they will always be available in the User Defined category in the Insert Function dialog box.


2 Answers

I suggest further investigating the Application.MacroOptions method. That method allows you to provide not only a description for the function, but also a description for each of the arguments. For example, if you have a function called "SampleFunction" that takes two arguments, you can run the following and it will set you up nicely for using the fx button with your function.:

Private Sub RegisterMyFunction()
    Application.MacroOptions _
        Macro:="SampleFunction", _
        Description:="calculates a result based on provided inputs", _
        Category:="My UDF Category", _
        ArgumentDescriptions:=Array( _
            "is the first argument.  tell the user what it does", _
            "is the second argument.  tell the user what it does")
End Sub
like image 43
Kendall Avatar answered Oct 02 '22 11:10

Kendall


Type =FormulaName( into a cell and then press Ctrl+Shift+A and it will fill in the reference name of the arguments

like image 154
JustinJDavies Avatar answered Oct 02 '22 11:10

JustinJDavies