Intellisense in VBA custom function?

In the standard VBA IDE, intellisense is built into many standard VBA functions. those. the button variable for msgbox () gives you a list of options for how you want to display the message box. Thus, the developer does not need to remember or search for parameters every time the function is used.

Can I achieve the same for my custom VBA functions? This is an example, but I can write something like:

Public Function DoSomething(X as string)(Options X="Opt1","Opt2") as variant
...

When I call this function, I get a popup providing my options for X like Opt1 and Opt2

+4
source share
1 answer

You will need to declare your own enumerations, and then define the parameter for your functions as this numbered type.

 Public Enum eOptions Option1 Option2 End Enum public Function DoSomething(ByVal x as string, Byval MyOption as eOptions) 

When you call the ala function:

 Call DoSomething("myValue", Option2) 

You will see the values โ€‹โ€‹available for the second parameter for the function as "Option 1" or "Option2".

+8
source

Source: https://habr.com/ru/post/1305771/


All Articles