How to set an arg list for my VBA functions
You can use an Enum. Here is an example set up...
Enum MyDropDownList
Top = 1
AboveCenter
Center
BelowCenter
Bottom
End Enum
Function MyFunction(Arg1 As MyDropDownList)
Debug.Print Arg1
End Function
Now, inside your own subroutine or function, when you type MyFunction and
the opening parentheses, you will be presented with the list from the Enum
above. The way I set it up, Top=1, AboveCenter=2, Center=3, etc. You can,
however, assign any starting value to the first element of the Enum and the
rest, if not explicitly assigned, will take on the next consecutive value.
On the other hand, you can assign the equivalent value (not necessarily in
consecutive order) to the elements of the Enum line by line. For example...
Enum MyDropDownList
Top = 10
AboveCenter = 5
Center = 0
BelowCenter = -5
Bottom = -10
End Enum
Rick
"shelfish" wrote in message
...
I've written a function that I am using over and over again in the
rest of my code. One of the arguments is one of several acceptable
strings and I don't want to have to keep typing it with opportunity
for error. Ignoring error control practices, my question is, how can I
force VBE to give me a drop-down menu for my function like you would
see using, say, ".horizontalalignment =", where you would see xlLeft,
xlCenter, etc.
Many thanks for any assistance...and happy Memorial day.
S.
|