View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
IanKR IanKR is offline
external usenet poster
 
Posts: 97
Default How can I prevent #NA in Lookup

Can someone please advise me ; if VLOOKUP( ) doesn't find the result
in the formula,the the cell shows #NA. How can I get a cell to be
blank,if the value isn't found.

I have only just started using VLOOKUP & HLOOKUP,so any help would be
greatfully accepted. Thanks


I wrote my own UDF:

Function NewVLookup(Value As Variant, Table As Variant, _
ColIndex As Integer, RangeLookup As Boolean) As Variant
With Application
If .IsNA(.VLookup(Value, Table, _
ColIndex, RangeLookup)) Then
NewVLookup = 0 '<================ change 0 to
"" if you want blank instead of 0
Else
NewVLookup = .VLookup(Value, Table, ColIndex, RangeLookup)
End If
End With
End Function