Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default look up and ISNA in vba

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(Ra nge("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

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default look up and ISNA in vba

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

this is the complete excel function that I am trying to code

thank

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default look up and ISNA in vba

As before

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

not tested so you may need to teweak.

BTW LOOKUP and VLOOKUP are different.

--

HTH

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

"nyn04 " wrote in message
...
IF(ISNA(LOOKUP(A3,t!A:A,t!C:C))<TRUE,(LOOKUP(A3,t !A:A,t!C:C)),0)

this is the complete excel function that I am trying to code

thanks


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default look up and ISNA in vba

Using WorksheetFunction as a qualifier results in a trappable error rather
than return N/A when the value is not found. If you just use application
as the qualifier, then N/A is returned.

Dim res as Variant

res = Application.Lookup(Range("A3"),Range("t!A:A"),Rang e("t!C:C"))
if iserror(res) then
msgbox Range("A3").Value & " not found"
res = 0
else
msgbox "Found, return is " & res
End if

'at this point, res holds zero or the value returned.


So you don't need to do two lookups in VBA.

--
Regards,
Tom Ogilvy

"nyn04 " wrote in message
...
IF(ISNA(LOOKUP(A3,t!A:A,t!C:C))<TRUE,(LOOKUP(A3,t !A:A,t!C:C)),0)

this is the complete excel function that I am trying to code

thanks


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default look up and ISNA in vba

for Vlookup as shown it should be:

WorksheetFunction.VLookup(Range("A3"), _
worksheets("t").Range("A:C"), 3, False)

--
Regards,
Tom Ogilvy

"Bob Phillips" wrote in message
...
As before

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

not tested so you may need to teweak.

BTW LOOKUP and VLOOKUP are different.

--

HTH

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

"nyn04 " wrote in message
...
IF(ISNA(LOOKUP(A3,t!A:A,t!C:C))<TRUE,(LOOKUP(A3,t !A:A,t!C:C)),0)

this is the complete excel function that I am trying to code

thanks


---
Message posted from http://www.ExcelForum.com/





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ISNA Help Please Please please Mattlynn via OfficeKB.com Excel Worksheet Functions 6 March 8th 10 08:37 PM
IF(ISNA.... olrustyxlsuser Excel Discussion (Misc queries) 6 November 21st 08 11:46 PM
ISNA Help Bigfoot17 Excel Worksheet Functions 2 March 21st 07 05:58 PM
ISNA help Matt Excel Worksheet Functions 1 October 14th 06 05:56 PM
ISNA Lomax Excel Worksheet Functions 4 July 24th 05 05:41 PM


All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"