Search code examples
excelexcel-2007user-defined-functionsvba

Add help to "No help available" Excel, VBA , User defined functions


I was trying to add some help to my user-defined function(UDF) in Excel, written using VBA(Visual Basic for Applications). I know how to add a description.Any idea how I can add help at the blue link "Help on this function" and not have it lead to a MsgBox that reads "No help available" ?


Solution

  • You have to first create a help file. You can then use Application.MacroOptions to attach the help file to the function

    For example

    Application.MacroOptions Macro:="MyFunction", _
                             Category:="My Custom Category", _
                             HelpFile:="C:\MyHelp.chm", _
                             HelpContextID:=1
    

    EDIT: Adding More Information

    I usually use Help and Manual6 to create my help files for my projects. Here is one example that I created for the above example. And when I click on the "Help On this Function", see what do I get...

    enter image description here

    DISCLAIMER: I am not connected to Help and Manual6 in any way but I like their product (It is not free). You might just find a freeware on the web which can make chm files for you so I leave the decision with you on how you choose to make the help file.