I am trying to create a Vlookup function with an additional argument to
return if the vlookup function evaluates to #N/A (Below is the code).
It works fine unless the function evaluates to #N/A.
I would greatly appreciate any help,
Michael
Function VLOOKUP_NA(VAL1, Range, OFFSET, TF, NAVALUE)
If WorksheetFunction.IsNA(WorksheetFunction.VLookup(VAL1, Range, OFFSET,
TF)) <> False 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
2007-09-20
09:03:54
·
2 answers
·
asked by
msaathof
3
in
Computers & Internet
➔ Programming & Design
Thanks for the quick response; however, I still can't get it to work. I modified the code (see below); however, it the function evaluates to #N/A it is still not returning the "NAVALUE".
Function VLOOKUP_NA(VAL1, Range, OFFSET, TF, NAVALUE)
VLOOKUP_NA = WorksheetFunction.VLookup(VAL1, Range, OFFSET, TF)
If WorksheetFunction.IsNA(VLOOKUP_NA) = True Then
VLOOKUP_NA = NAVALUE
End If
End Function
2007-09-20
09:41:47 ·
update #1