Can I inspect an Excel function signature programmatically in VBA?

Viewed 1325

Rather than access all the arguments explicitly by name, is there a way to get a list of function arguments programmatically from within the function?

So for this function signature:

Function doSomething(Arg1 as String, Arg2 as Range, Optional Arg3 as String):

is there, ideally, an object that contains argument names and their metadata (type, optional, default value, etc.)? E.g., the code Me.Arguments inside this function would produce a dictionary something like this:

{
  "Arg1": {
    "Type": String,
    "Optional": False,
    "Default": Nothing
  },
  "Arg2": {
    "Type": Range,
    "Optional": False,
    "Default": Nothing
  },
  "Arg1": {
    "Type": String,
    "Optional": True,
    "Default": Nothing
  }
}

Thanks.

4 Answers
Related