Adding a Description and Category to your User Defined Functions in Excel

< Back to Search results

 Category: [Excel]  Demo Available 


Adding a Description and Category to your User Defined Functions in Excel



Got any Excel/VBA Questions? Free Excel Help. 

There are at least 2 ways you can use to add a description to you UDF's, one is relatively well known, while the other is a simple but little known method. Lets use the better known method first.

  1. Open Up The VBE (Alt+F11) And Select Anywhere Within Your Function Code.
  2. Now Push F2 To Open The "Object Browser".
  3. At The Top Of The Object Browser There Are 2 Drop Down Boxes. Click The Top One And Select "VBAProject".
  4. You Should Now Have All Modules And Global Objects Showing In The "Classes" Box Situated At The Bottom Of The Object Browser.
  5. Click On The Name Of The Module That Houses Your UDF.
  6. In The "Members Of..." Box To The Right You Should See The Names Of All Functions And Procedures Within The Selected Module.
  7. Simply Right Click On The Name Of Your UDF And Select "Properties".
  8. Type A Description For Your UDF, Then Click Ok And Then Save.

Now here is the little known method. This is best done before you write your UDF.

  1. Go To Tools>Macro>Record New Macro.
  2. In The Description Box, Type A Description For Your UDF. Type The Name Of Your UDF And Click Ok.
  3. Now Stop Recording.
  4. Open The VBE (Alt+F11) And Replace The Word "Sub" With "Function"
  5. Add Your Function Arguments As Normal.

How to add your UDF to a category

Another common question is, how to add your UDF to a certain category in the "Paste Function" dialog. By default all UDF's are added to the "User Defined" category. Here is how you can change this.

Simply run some code like this:

Application.MacroOptions Macro:="MyCustomFunction", _

 Category:=3'Add to Math & Trig

The category numbers are as shown below:

0 No category appears only in All
1 Financial
2 Date & Time
3 Math & Trig
4 Statistical
5 Lookup & Reference
6 Database
7 Text
8 Logical
9 Information
10 Commands normally hidden
11 Customizing normally hidden
12 Macro Control normally hidden
13 DDE/External normally hidden
14 User Defined default
15 Engineering only available if the Analysis Toolpak add-in is installed

How to add a new category

By default when you write a Custom function (UDF) it is added to the User Defined by default. Although not well known, we can easily create our own category(s) to keep all our Custom functions in, here's how

  1. Right-Click Any Sheet Name Tab And Select Insert. Now Select MS Excel 4.0 Macro And Click OK To Add A Macro Sheet To The Workbook.
  2. Go To Insert>Name>Define, Or Push Ctrl+F3. Within The Macro Box (Near Bottom Right), Click Function.
  3. In The Names In Workbook: Box, Type Any One Word Name, I'll Use MyFunction .
  4. From The Category Box Select User Defined. Now Replace "User Defined" With Your New Category Name, And Then Click OK.

Microsoft Excel will add the new category to the list for you. Once you have added at least one custom function to the new category (it will be probably be # 16), you can delete the "MyFunction" (or whatever name you used) name we typed in step 3. The new category will remain. If you delete the Microsoft Excel 4.0 macro sheet, functions already assigned to the custom category remain in that category; however, you cannot assign a new function to that category after you delete the macro sheet.


See also:

Delete Module After Running VBA Code
Deleting Excel Named Ranges
Delete Excel Sheet Event Code Macro
Delete Excel Workbook Event Code
Matching ComboBox Controls


Free Training Course: Lesson 1 - Excel Fundamentals


See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions


Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. If you’re looking for high-quality organic dried fruits you’ve come to the right place OzGrid is in no way associated with Microsoft.


Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.




stars (0 Reviews)