Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Vlookup in VBA

when trying to use vlooku in vba
Application.WorksheetFunction.VLookup( ...)
I am getting the following vba error
Run-time error 1004
Unable to get the Vlookup property of the worksheetFunction class.

Any idea what I am missing?
Thanks
Dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Vlookup in VBA

application.worksheetfunction.vlookup() will cause a runtime error if there is
no match.

You can trap that error:

dim res as variant 'long, string???
on error resume next
res = application.worksheetfunction.vlookup(...)
if err.number < 0 then
'an error occurred
err.clear
res = "not found"
end if
msgbox res

====

But application.vlookup() will return an error you can check for:

I'd use something like:

dim Res as variant
res = application.vlookup(...)
if iserror(res) then
res = "not found"
end if
msgbox res

I find the application.vlookup() easier to use.

And the same thing for application.match() v.
application.worksheetfunction.match().




Dan wrote:

when trying to use vlooku in vba
Application.WorksheetFunction.VLookup( ...)
I am getting the following vba error
Run-time error 1004
Unable to get the Vlookup property of the worksheetFunction class.

Any idea what I am missing?
Thanks
Dan


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Vlookup in VBA

Not to pick but you should probably switch the error handler back to normal
mode at some point...

dim res as variant 'long, string???
on error resume next
res = application.worksheetfunction.vlookup(...)
if err.number < 0 then
'an error occurred
err.clear
res = "not found"
end if
On Error Goto 0
msgbox res

--
HTH...

Jim Thomlinson


"Dave Peterson" wrote:

application.worksheetfunction.vlookup() will cause a runtime error if there is
no match.

You can trap that error:

dim res as variant 'long, string???
on error resume next
res = application.worksheetfunction.vlookup(...)
if err.number < 0 then
'an error occurred
err.clear
res = "not found"
end if
msgbox res

====

But application.vlookup() will return an error you can check for:

I'd use something like:

dim Res as variant
res = application.vlookup(...)
if iserror(res) then
res = "not found"
end if
msgbox res

I find the application.vlookup() easier to use.

And the same thing for application.match() v.
application.worksheetfunction.match().




Dan wrote:

when trying to use vlooku in vba
Application.WorksheetFunction.VLookup( ...)
I am getting the following vba error
Run-time error 1004
Unable to get the Vlookup property of the worksheetFunction class.

Any idea what I am missing?
Thanks
Dan


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Vlookup in VBA

Are capturing the result someplace?
if you don't have something like:
res=Application.WorksheetFunction.VLookup( ...)

then it might be trying to use it as a property not a method

"Dan" wrote:

when trying to use vlooku in vba
Application.WorksheetFunction.VLookup( ...)
I am getting the following vba error
Run-time error 1004
Unable to get the Vlookup property of the worksheetFunction class.

Any idea what I am missing?
Thanks
Dan

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

Yep.

Thanks for the addition.

Jim Thomlinson wrote:

Not to pick but you should probably switch the error handler back to normal
mode at some point...

dim res as variant 'long, string???
on error resume next
res = application.worksheetfunction.vlookup(...)
if err.number < 0 then
'an error occurred
err.clear
res = "not found"
end if
On Error Goto 0
msgbox res

--
HTH...

Jim Thomlinson

"Dave Peterson" wrote:

application.worksheetfunction.vlookup() will cause a runtime error if there is
no match.

You can trap that error:

dim res as variant 'long, string???
on error resume next
res = application.worksheetfunction.vlookup(...)
if err.number < 0 then
'an error occurred
err.clear
res = "not found"
end if
msgbox res

====

But application.vlookup() will return an error you can check for:

I'd use something like:

dim Res as variant
res = application.vlookup(...)
if iserror(res) then
res = "not found"
end if
msgbox res

I find the application.vlookup() easier to use.

And the same thing for application.match() v.
application.worksheetfunction.match().




Dan wrote:

when trying to use vlooku in vba
Application.WorksheetFunction.VLookup( ...)
I am getting the following vba error
Run-time error 1004
Unable to get the Vlookup property of the worksheetFunction class.

Any idea what I am missing?
Thanks
Dan


--

Dave Peterson


--

Dave Peterson
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
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
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


All times are GMT +1. The time now is 10:18 PM.

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"