View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Finance Guru Finance Guru is offline
external usenet poster
 
Posts: 83
Default How can I prevent #NA in Lookup

Hi Ian - Thanks for replying,but i think this way ahead of me,I am not a
programmer. I wouldn't even begin to know where to start.

Thanks anyway
FinanceGuru

"IanKR" wrote:

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