M
Michael Saathoff
I am trying to write a simple Excel VBA Function and I am running into
trouble. The function is a simple Vlookup with an additional argument to
return if the Vlookup evaluates to #N/A.
If the Lookup function does not evaluate to #N/A the function works fine;
however, I get an error if it evaluates to #N/A.
Below is the code and I would greatly appreciate help.
Michael
Code:
Function VLOOKUP_NA(VAL1, RANGE, OFFSET, TF, NAVALUE)
If WorksheetFunction.IsNA(WorksheetFunction.VLookup(VAL1, RANGE, OFFSET,
TF)) = True Then
VLOOKUP_NA = NAVALUE
ElseIf WorksheetFunction.IsNA(WorksheetFunction.VLookup(VAL1, RANGE, OFFSET,
TF)) = False Then
VLOOKUP_NA = WorksheetFunction.VLookup(VAL1, RANGE, OFFSET, TF)
End If
End Function
trouble. The function is a simple Vlookup with an additional argument to
return if the Vlookup evaluates to #N/A.
If the Lookup function does not evaluate to #N/A the function works fine;
however, I get an error if it evaluates to #N/A.
Below is the code and I would greatly appreciate help.
Michael
Code:
Function VLOOKUP_NA(VAL1, RANGE, OFFSET, TF, NAVALUE)
If WorksheetFunction.IsNA(WorksheetFunction.VLookup(VAL1, RANGE, OFFSET,
TF)) = True Then
VLOOKUP_NA = NAVALUE
ElseIf WorksheetFunction.IsNA(WorksheetFunction.VLookup(VAL1, RANGE, OFFSET,
TF)) = False Then
VLOOKUP_NA = WorksheetFunction.VLookup(VAL1, RANGE, OFFSET, TF)
End If
End Function