Thursday, January 9, 2014

Custom Function or UDF (user defined functions)-2

Adding description to custom functions(UDF)

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. Let’s use the better known method first.
Open Up the VBE (Alt+F11) and Select Anywhere Within Your Function Code.
Now Push F2 To Open The "Object Browser".
At The Top Of The Object Browser There Are 2 Drop Down Boxes. Click The Top One And Select "VBAProject".
You Should Now Have All Modules And Global Objects Showing In The "Classes" Box Situated At The Bottom Of The ObjectBrowser.
Click On The Name Of The Module That Houses Your UDF.
In The "Members Of..." Box to the Right You Should See the Names of All Functions and Procedures Within The Selected Module.
Simply Right Click On The Name Of Your UDF And Select "Properties".
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.

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


No comments:

Post a Comment