IsMissing is a built-in function that can be used to see if an optional, Variant argument was passed to a sub or function. Since optional arguments are, well, optional, your code needs to determine if they’ve been supplied. If the optional argument is declared as a Variant data type, the IsMissing function will tell you if the argument has been supplied or omitted.
I’m sure I’ve used IsMissing in the past, but it’s very rare. There’s a trade-off. To use IsMissing, the argument must be declared as a Variant, and no other data type. In that case, I lose the benefits of strong data typing. For instance, I would have to declare a string as a Variant just to use IsMissing.
The other side is that VBA provides defaults for strongly typed optional arguments. If my optional argument is typed as Long and it’s omitted, it becomes a zero. If my optional argument is typed as String and omitted, it becomes a zero length string. That’s not necessarily bad, unless I need to distinguish if a zero was passed or the argument was omitted. For Long optional arguments, there’s no way to tell the difference.
A third possibility is supplying my own defaults, which I almost always do. I can declare optional argument thusly:
All I’ve done is replace the default default with my own default, that is a zero length string with Joe. I still have the problem that I won’t know if Joe was passed or the argument was omitted, but since I have a specific case as the default, it’s less likely to matter.