#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Vlookup?

what the difference between...

Worksheetfunction.Vlookup()

and...

Application.Vlookup()

???


What the benefit of using one over the other???
Are there special circumstance or situation where you might wanna use one of
them, but in other cases it is preferable to use the other?


TIA,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Vlookup?

One of the differences is the way they behave:

Application.vlookup returns an error that you can check:

dim Res as variant 'could return an error
res = application.vlookup(....)
if iserror(res) then
msgbox "no match"
else
msgbox res
end if

Application.worksheetfunction.vlookup raises a trappable error that you have to
catch:

dim res as variant
on error resume next
res = application.worksheetfunction.vlookup(...)
if err.number < 0 then
msgbox "no match"
else
msgbox res
end if
on error goto 0

(application.match() and application.worksheetfunction.match() behave the same
way.)

Personally, I find using the application.vlookup() syntax easier to read. But
it's personal preference.

Charlotte E wrote:

what the difference between...

Worksheetfunction.Vlookup()

and...

Application.Vlookup()

???

What the benefit of using one over the other???
Are there special circumstance or situation where you might wanna use one of
them, but in other cases it is preferable to use the other?

TIA,


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vlookup?

They are the same when you are in excel. If you opened an excel workbook
from another office product you would need the application or if you used
GetObject to get the workbook.


If you are in VBA it is more efficient to use FIND

set c = Columns("A").Find(what:="abc",lookin:=xlvalues,loo kat:=xlwhole)
if Not c is nothing then

end if

Find is better becaue you don't get an error when the item doesn't exist.
You get Nothing which you can test for.

"Charlotte E" wrote:

what the difference between...

Worksheetfunction.Vlookup()

and...

Application.Vlookup()

???


What the benefit of using one over the other???
Are there special circumstance or situation where you might wanna use one of
them, but in other cases it is preferable to use the other?


TIA,



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
VLookUp - Does the VLookUp return the exact information? Cpviv Excel Worksheet Functions 2 October 28th 08 09:57 AM
using a vlookup to enter text into rows beneath the vlookup cell Roger on Excel Excel Programming 1 November 29th 07 12:09 PM
Combine VLOOKUP and IF function so #NA isn't returned as a value from VLOOKUP buffgirl71 Excel Discussion (Misc queries) 12 November 14th 06 11:36 PM
Which is faster: VLOOKUP-worksheet or VB-array VLOOKUP? erikhs[_20_] Excel Programming 1 August 6th 06 06:18 PM
Vlookup -=VLOOKUP(F9,LookUp1!$A$2:$B$1504,2,FALSE) MikeR-Oz New Users to Excel 1 March 22nd 06 09:01 AM


All times are GMT +1. The time now is 07:01 PM.

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

About Us

"It's about Microsoft Excel"