Search code examples
excelvbacustom-function

Excel VBA custom functions help dialog


I've been making lots of functions over the years for Excel VBA, but I've always wondered how to make a more detailed help dialog box.

For built in functions, you get something like this:

enter image description here

How can I do things like this, where it shows the variable type, and if it has a default, what that value is. I've seen some things in the past where if you export the file, then add some code in a text editor, then import it back it, you can get extra functionality that Excel VBA doesn't natively support... wasn't sure if something like that also existed for this type of functionality.

Thanks in advance!


Solution

  • Instr is defined in VBA like this:

    Function InStr([Start], [String1], [String2], [Compare As VbCompareMethod = vbBinaryCompare])
    

    VbCompareMethod is an enumeration with 3 members. You can define functions to use enumerations as well if you like (even custom ones you create).

    In this case, the enumeration is just a choice of a few different integer values. They are useful in limiting which integers are accepted in the routine, for future readability, and in helping the programmer know more easily what options are available using intellisense (I think you are calling intellisense a "help dialog")