VLOOKUP in VBA returns run-time error 424

Brucefield

New Member
Joined
Apr 23, 2009
Messages
3
I'm trying to use VLOOKUP in VBA to add a value to a variable:

LizTeamName = Application.WorksheetFunction.VLookup(TeamName, Range("TeamNameLookup"), 3, False).Value

The macro stops at this line with the following error

Run-time error '424': Object Required

What I'm trying to do: Range "TeamNameLookup" is in the active file, albeit in a different sheet. It's 4 columns wide, and the value I want to return is in column 3. The variable "TeamName" is populated with a value that's definitely in the first column of the named range. My feel is that for some reason Excel/VBA wants an object attached to the end of Range("TeamNameLookup"), if only because that's the only bit of the code that could possibly have an object added to it!

Any thoughts? Thanks in advance!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
VoG, Thanks for trying...

Syntax now reads:

HTML:
LizTeamName = Application.WorksheetFunction.VLookup(TeamName, Range("TeamNameLookup"), 3, False)

Error is now:

HTML:
Run-time Error '1004': Method 'Range' of object '_Global' failed

As you've probably guessed, I've been tweaking the code for a while before coming online. Unfortunately I've recently moved to a different company (I'm a contractor) so my library of VBA has to be started again...
 
Upvote 0
Hi Bruce

Is that a sheet-level defined name? If so, does it work if you prefix the Range() with the sheet name ie:

LizTeamName = Application.WorksheetFunction.VLookup(TeamName, Sheets("YourSheetName").Range("TeamNameLookup"), 3, False)
 
Upvote 0
Hi,

Is team name defined in a variable within the code or a Defined Name as worksheet level? Is TeamNameLookup definitely 3 columns wide?
 
Upvote 0
Richard,

You've cracked it! :)

VoG and Mike - thanks for your help too...

Now to try and put something back in by helping someone else, time permitting...

Thanks,

Chris (I know, it's counter-intuitive user name!)
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top