lookup in vba

N

nyn04

I am trying to write a vba code that accomplished the following exce
code,

can anyone help

=IF(ISNA(VLOOKUP(...)),"",VLOOKUP(...))

I have wrriten the following

If WorksheetFunction.IsNA(WorksheetFunction.Lookup(Range("a3")
Range("j1:j5"), Range("l1:l5"))) = True Then ....

but when I run I get an error messege telling that I can not find th
lookup function, I think its due to the fact that the return is N/
since when I put on a cell that has an answear I get a response
 
B

Bob Phillips

This works for me

Dim ans
On Error Resume Next
ans = WorksheetFunction.VLookup(Range("A3"), Range("J1:J5"), 2, False)
On Error GoTo 0
If ans = "" Then
MsgBox "Empty"
Else
MsgBox ans
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
N

nyn04

my complet function is the following

=IF(ISNA(LOOKUP(A3,t!A:A,t!C:C))<>TRUE,(LOOKUP(A3,t!A:A,t!C:C)),0)

will that code work??

thank
 
Top