K
ker_01
I have a UDF with an optional *range* parameter, and whether one block of
code should run depends on whether or not a range was supplied.
I tried ISMISSING(OptionalRangeParameter) but even when the range is not
passed through, it apparently doesn't evaluate as missing.
I also tried ISNULL and ISEMPTY, to the same effect.
I also tried the ubound>lbound trick for arrays, but that didn't work
(presumably because this is a range, or because the parameter hadn't been
passed in the first place, I'm not sure)
What is the most reliable method of determining if an optional range
parameter was used?
When the parameter isn't used and my code processes anyway, it causes my
code to ungracefully fail when trying to set an array equal the the values in
the (optional) range.
Thanks!
Keith
Code:
Function ParseDataForJerry(StrSourceRange As Range, Optional MatchListRng As
Range, Optional CharFormat As String)
'StrSourceRange As Range: This is the cell with the irregularly
formatted source data
'Optional MatchListRng As Range: This is a list that contains possible matches
'Optional CharFormat As String: This is searching for only a single,
specific format
If Not (IsMissing(MatchListRng)) Then
Dim cList As Variant
cList = MatchListRng.Value <--runs and fails here even when parameter is
empty
End If
....code continues
code should run depends on whether or not a range was supplied.
I tried ISMISSING(OptionalRangeParameter) but even when the range is not
passed through, it apparently doesn't evaluate as missing.
I also tried ISNULL and ISEMPTY, to the same effect.
I also tried the ubound>lbound trick for arrays, but that didn't work
(presumably because this is a range, or because the parameter hadn't been
passed in the first place, I'm not sure)
What is the most reliable method of determining if an optional range
parameter was used?
When the parameter isn't used and my code processes anyway, it causes my
code to ungracefully fail when trying to set an array equal the the values in
the (optional) range.
Thanks!
Keith
Code:
Function ParseDataForJerry(StrSourceRange As Range, Optional MatchListRng As
Range, Optional CharFormat As String)
'StrSourceRange As Range: This is the cell with the irregularly
formatted source data
'Optional MatchListRng As Range: This is a list that contains possible matches
'Optional CharFormat As String: This is searching for only a single,
specific format
If Not (IsMissing(MatchListRng)) Then
Dim cList As Variant
cList = MatchListRng.Value <--runs and fails here even when parameter is
empty
End If
....code continues