View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Michael Saathoff Michael Saathoff is offline
external usenet poster
 
Posts: 1
Default Simple Excel VBA Question

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(V AL1, Range, OFFSET,
TF)) < False Then
VLOOKUP_NA = NAVALUE
ElseIf WorksheetFunction.IsNA(WorksheetFunction.VLookup(V AL1, Range, OFFSET,
TF)) = False Then
VLOOKUP_NA = WorksheetFunction.VLookup(VAL1, Range, OFFSET, TF)
End If

End Function