View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mickey mickey is offline
external usenet poster
 
Posts: 112
Default Optional Parameter Testing

By the way just got a chance the test your suggestion - it worked perfectly.
The "Is" operator made all the difference.

Thanks again ;-)


"mickey" wrote:

Thanks Very Much JMB!

I think it's going to work, but unfortunately the machine I'm currently at
doesn't have Excel 2003 and I'm using "ThisCell": It's my understanding that
"ThisCell" is not available on versions older than 2003. A full check will
have to wait till I'm on my other machine.

Funny thing is the first thing I tried was equating the range variable to
"Nothing", but I neglected to use the "Is" operator in the evaluation routine.

Thanks again for your response. :-)


"JMB" wrote:

this appeared to work for me

Function TestMe(Optional rng As Range = Nothing)
If rng Is Nothing Then
TestMe = "Nothing"
Else: TestMe = rng.Address
End If
End Function


"mickey" wrote:

How do you test for an "Optional" function parameter if it's a "Range"(e.g.
Function X (I As Integer, Optional Cell As Range)?

The "IsMissing()" function is only valid for "Variants", and according to
the help-file, one can test for other types of parameters by testing for
their "Default" values (e.g. Function X (I As Integer, Optional S As String =
"xyz"). If "S" isn't specified it will take on the value of "xyz", which can
be tested.

Does anyone know how and what can be assigned as a default to a "Range"
parameter so it's existence can be tested?

Thanks.