Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default application.worksheetfunction.vlookup

Hi

for the first time i'm using worksheet functions in vba and was surprised to
find that
k =
application.worksheetfunction.vlookup(pipes(j),She ets("Database").Range("Pip
e_Number"),2,0)

shows k as empty rather than "erroring" or #NA .. i tried to get a handle on
this in vba help but it didn't seem to explain this behaviour - can anyone
explain to me why and, in some ways, more importantly how i can get "k" to
"error" if the item isn't found?

Thanks
JulieD


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default application.worksheetfunction.vlookup

Julie, when I try it certainly does error when the item is not found. I
would suggest that it does find the item in the 1st column but that the cell
in the second column is empty and so this empty value is returned. This is
not an error since the item is found.

Fred

"JulieD" wrote in message
...
Hi

for the first time i'm using worksheet functions in vba and was surprised

to
find that
k =

application.worksheetfunction.vlookup(pipes(j),She ets("Database").Range("Pip
e_Number"),2,0)

shows k as empty rather than "erroring" or #NA .. i tried to get a handle

on
this in vba help but it didn't seem to explain this behaviour - can anyone
explain to me why and, in some ways, more importantly how i can get "k" to
"error" if the item isn't found?

Thanks
JulieD




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default application.worksheetfunction.vlookup

Hi Julie
this happens if the item is not found. One way arround it:

on error resume next
kapplication.worksheetfunction.vlookup(...)
if err.number<0 then
k="Error"
end if
on error goto 0
msgbox k


-----Original Message-----
Hi

for the first time i'm using worksheet functions in vba

and was surprised to
find that
k =
application.worksheetfunction.vlookup(pipes(j),Sh eets

("Database").Range("Pip
e_Number"),2,0)

shows k as empty rather than "erroring" or #NA .. i tried

to get a handle on
this in vba help but it didn't seem to explain this

behaviour - can anyone
explain to me why and, in some ways, more importantly how

i can get "k" to
"error" if the item isn't found?

Thanks
JulieD


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default application.worksheetfunction.vlookup

Hi Fred

thanks for your reply ... now i know what i did ...(the light's just gone
on!), the first half dozen or so times i ran it it did error and then i made
some changes for another reason and populated lookup value column with the
value prior to this bit of code, which is why it no longer errors out ....
because, as you said, it is there, but the second column is blank.

okay i might have to see if Frank's method will cause it to error out ....

Thanks again
JulieD


"fred" wrote in message
...
Julie, when I try it certainly does error when the item is not found. I
would suggest that it does find the item in the 1st column but that the

cell
in the second column is empty and so this empty value is returned. This is
not an error since the item is found.

Fred

"JulieD" wrote in message
...
Hi

for the first time i'm using worksheet functions in vba and was

surprised
to
find that
k =


application.worksheetfunction.vlookup(pipes(j),She ets("Database").Range("Pip
e_Number"),2,0)

shows k as empty rather than "erroring" or #NA .. i tried to get a

handle
on
this in vba help but it didn't seem to explain this behaviour - can

anyone
explain to me why and, in some ways, more importantly how i can get "k"

to
"error" if the item isn't found?

Thanks
JulieD






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default application.worksheetfunction.vlookup

Hi Frank

sorry haven't tried your code, (the workbook's at work), but just looking at
it, doesn't this just set the value of k to the word "error", what i'm
wanting to do is force it to have an error and drop to the error handling
routine.

Cheers
JulieD

"Frank Kabel" wrote in message
...
Hi Julie
this happens if the item is not found. One way arround it:

on error resume next
kapplication.worksheetfunction.vlookup(...)
if err.number<0 then
k="Error"
end if
on error goto 0
msgbox k


-----Original Message-----
Hi

for the first time i'm using worksheet functions in vba

and was surprised to
find that
k =
application.worksheetfunction.vlookup(pipes(j),Sh eets

("Database").Range("Pip
e_Number"),2,0)

shows k as empty rather than "erroring" or #NA .. i tried

to get a handle on
this in vba help but it didn't seem to explain this

behaviour - can anyone
explain to me why and, in some ways, more importantly how

i can get "k" to
"error" if the item isn't found?

Thanks
JulieD


.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default application.worksheetfunction.vlookup

Another way is to use only application as the qualifier

Dim res as Variant
res = Application.Vlookup()
if iserror(res) then
msgbox "Not found"
Else
msgbox "Value returned is " & res
End if

If you use worksheetfunction as the qualifier, then it returns a trappable
error (1004 type error).

--
Regards,
Tom Ogilvy

"Frank Kabel" wrote in message
...
Hi Julie
this happens if the item is not found. One way arround it:

on error resume next
kapplication.worksheetfunction.vlookup(...)
if err.number<0 then
k="Error"
end if
on error goto 0
msgbox k


-----Original Message-----
Hi

for the first time i'm using worksheet functions in vba

and was surprised to
find that
k =
application.worksheetfunction.vlookup(pipes(j),Sh eets

("Database").Range("Pip
e_Number"),2,0)

shows k as empty rather than "erroring" or #NA .. i tried

to get a handle on
this in vba help but it didn't seem to explain this

behaviour - can anyone
explain to me why and, in some ways, more importantly how

i can get "k" to
"error" if the item isn't found?

Thanks
JulieD


.



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
Reuse Application.WorksheetFunction jlclyde Excel Discussion (Misc queries) 4 March 12th 09 08:32 PM
Need help with Application.WorksheetFunction Ayo Excel Discussion (Misc queries) 4 May 14th 08 11:13 PM
Application.WorksheetFunction.Upper y Excel Programming 6 April 8th 04 12:43 PM
application.worksheetfunction.mmult help Alex[_13_] Excel Programming 2 October 29th 03 10:13 PM
Using Application.WorksheetFunction.Ln(...) in VBA doco Excel Programming 4 August 25th 03 01:08 PM


All times are GMT +1. The time now is 03:31 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"