Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mbs function argument "is missing"

Status
Not open for further replies.

rgandy

Technical User
Nov 17, 2005
38
US
all,
wondering if anyone knows how excel can capture a "missing" argument WITHOUT required a conditional ismissing function in the subsequent code

can the argument be defined in such a way as to catch missing arguments and provide them default values or at least make it so that the missing nature of the argument does not crap out the program?
thanks
 

Just typing optional arguments is enough to initialise them and stop them being "Missing". So
Code:
[blue]Function(Optional arg)
    If IsMissing(arg) Then [green]' Might be True[/green]
    :
    :[/blue]
but
Code:
[blue]Function(Optional arg as string)
    If IsMissing(arg) Then [green]' Will never be True[/green]
    :
    :[/blue]
It more-or-less works in the same way as Dimming variables - a Variant can be empty but a typed (non-object) variable is always initialised.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top