Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Trouble using VLookup in VBA

Hi Everyone,
MS Excel 2003 SP3:
VLookup is on the list of functions available listed by Help, but the
folowing code generates the error "Sub or Function not defined".

If IsNA(VLookup(sT, "WasinoParts", 1, True)) = False Then
IsWONPart = True
End If

The blue light is on "VLookup". Seems it is OK with IsNA. I am
thinking I need to load a reference library but can anyone tell me
which one? The list is long and bewildering. The ones I have loaded
are as follows:
Visual Basic for Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Your help would be very much appreciated!
Thank You,
-plh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Trouble using VLookup in VBA

Hi,
I figured it out:
With Application.WorksheetFunction
If .IsNA(.VLookup(sT, "WasinoParts", 1, True)) = False Then
IsWONPart = True
End If
End With
Thanx,
-plh


On Jul 22, 10:08*am, plh wrote:
Hi Everyone,
MS Excel 2003 SP3:
VLookup is on the list of functions available listed by Help, but the
folowing code generates the error "Sub or Function not defined".

* * If IsNA(VLookup(sT, "WasinoParts", 1, True)) = False Then
* * * *IsWONPart = True
* * End If

The blue light is on "VLookup". Seems it is OK with IsNA. I am
thinking I need to load a reference library but can *anyone tell me
which one? The list is long and bewildering. The ones I have loaded
are as follows:
Visual Basic for Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 *Object Library
Your help would be very much appreciated!
Thank You,
-plh


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Trouble using VLookup in VBA

Actually I am not out of the woods yet. I am getting RT error 1004
"Unable to get the VLookup property of the WorksheetFunction class"
Can anyone help me with this problem?
Thanks,
-plh
On Jul 22, 11:28*am, plh wrote:
Hi,
I figured it out:
* * With Application.WorksheetFunction
* * * * If .IsNA(.VLookup(sT, "WasinoParts", 1, True)) = False Then
* * * * * *IsWONPart = True
* * * * End If
* * End With
Thanx,
-plh

On Jul 22, 10:08*am, plh wrote:



Hi Everyone,
MS Excel 2003 SP3:
VLookup is on the list of functions available listed by Help, but the
folowing code generates the error "Sub or Function not defined".


* * If IsNA(VLookup(sT, "WasinoParts", 1, True)) = False Then
* * * *IsWONPart = True
* * End If


The blue light is on "VLookup". Seems it is OK with IsNA. I am
thinking I need to load a reference library but can *anyone tell me
which one? The list is long and bewildering. The ones I have loaded
are as follows:
Visual Basic for Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 *Object Library
Your help would be very much appreciated!
Thank You,
-plh- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Trouble using VLookup in VBA

OK, I'll bite: I was able to solve that one by searchin on this group
and the Internet at large. I'll have to be less quick to post next
time I run into a problem.
-plh

On Jul 22, 11:37*am, plh wrote:
Actually I am not out of the woods yet. I am getting RT error 1004
"Unable to get the VLookup property of the WorksheetFunction class"
Can anyone help me with this problem?
Thanks,
-plh
On Jul 22, 11:28*am, plh wrote:



Hi,
I figured it out:
* * With Application.WorksheetFunction
* * * * If .IsNA(.VLookup(sT, "WasinoParts", 1, True)) = False Then
* * * * * *IsWONPart = True
* * * * End If
* * End With
Thanx,
-plh


On Jul 22, 10:08*am, plh wrote:


Hi Everyone,
MS Excel 2003 SP3:
VLookup is on the list of functions available listed by Help, but the
folowing code generates the error "Sub or Function not defined".


* * If IsNA(VLookup(sT, "WasinoParts", 1, True)) = False Then
* * * *IsWONPart = True
* * End If


The blue light is on "VLookup". Seems it is OK with IsNA. I am
thinking I need to load a reference library but can *anyone tell me
which one? The list is long and bewildering. The ones I have loaded
are as follows:
Visual Basic for Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 *Object Library
Your help would be very much appreciated!
Thank You,
-plh- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Trouble using VLookup in VBA

Even though you found an answer, I like this technique:

Dim res as variant 'could return an error
dim LookUpCol as range

set lookupcol = worksheets("somesheetname").range("A1:A10") 'whatever??

res = application.match(sT, lookupcol, false)

if iserror(res) then
msgbox "not found"
else
msgbox "Found in row: " & res & " of the lookupcol"
end if

========
A couple of things...

I changed the function to =match() and I looked for an exact match. Since
you're only looking to see if the value is in the list, I figured =match() was
sufficient.

But changing to look for an exact match may not be what you want! You can look
at Excel's help to see what that third parm (-1, 0, 1) can do.

But the biggest thing I did was to drop the .worksheetfunction from the code.

There's a difference between how
application.vlookup() and application.vlookup()
and
application.match() and application.worksheetfunction.match()
works.

The first returns an error that can be checked -- that's why I like it.

The second causes a runtime error that has to be avoided with "on error" code.


On 07/22/2010 11:46, plh wrote:
OK, I'll bite: I was able to solve that one by searchin on this group
and the Internet at large. I'll have to be less quick to post next
time I run into a problem.
-plh

On Jul 22, 11:37 am, wrote:
Actually I am not out of the woods yet. I am getting RT error 1004
"Unable to get the VLookup property of the WorksheetFunction class"
Can anyone help me with this problem?
Thanks,
-plh
On Jul 22, 11:28 am, wrote:



Hi,
I figured it out:
With Application.WorksheetFunction
If .IsNA(.VLookup(sT, "WasinoParts", 1, True)) = False Then
IsWONPart = True
End If
End With
Thanx,
-plh


On Jul 22, 10:08 am, wrote:


Hi Everyone,
MS Excel 2003 SP3:
VLookup is on the list of functions available listed by Help, but the
folowing code generates the error "Sub or Function not defined".


If IsNA(VLookup(sT, "WasinoParts", 1, True)) = False Then
IsWONPart = True
End If


The blue light is on "VLookup". Seems it is OK with IsNA. I am
thinking I need to load a reference library but can anyone tell me
which one? The list is long and bewildering. The ones I have loaded
are as follows:
Visual Basic for Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Your help would be very much appreciated!
Thank You,
-plh- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



--
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
Trouble with Vlookup Hawksby Excel Discussion (Misc queries) 2 July 1st 09 04:00 PM
VLOOKUP Trouble [email protected] Excel Programming 0 April 24th 07 02:36 PM
Trouble with vLookup lcks via OfficeKB.com New Users to Excel 1 June 7th 06 09:23 AM
VLOOKUP trouble .. HELP! Dylan Moran Excel Worksheet Functions 2 December 7th 04 07:25 AM
VLookup with VBA trouble :-( Dave Peterson[_3_] Excel Programming 0 August 13th 04 12:49 AM


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