vlookup in VB

Sarah K

New Member
Joined
Nov 26, 2008
Messages
24
Hi there.

I'm trying to do a vlookup in Vb, I've come up with the following but it's not working (and it's not because I haven't defined the variables or anything, i just don't know the correct code for the vlookup in vb (it's clear as crystal when I'm doing one in a cell in the excel worksheet!)).
Using excel 2002.

application.vlookup(range(cells(i,2)),windows(x).sheets(y).range(E:H),2,false)

thanking you :)
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
Last I checked, winders didn't have no sheets fer chillens. Sheets' parents are workbooks. And yer gonna need to put that "E:H" bit inside some quotation marks.
 
Upvote 0

Sarah K

New Member
Joined
Nov 26, 2008
Messages
24
Hi
I tried recording a macro, but that puts the vlookup in a cell and I want it to live in vb.
Any suggestions?
 
Upvote 0

joy_666

Board Regular
Joined
Dec 10, 2008
Messages
121
Hey,

You want the code to be pasted until the last row of some defined column...

Is that your requirement?????
 
Upvote 0

Sarah K

New Member
Joined
Nov 26, 2008
Messages
24
Hi
Yes, I'm going to have to do this lots, so want the most efficient code possible. I will have a column of values in one workbook and I will need to do the vlookup for each of the column entries in a different workbook. Do vlookups actually exist in VB?? :(
 
Upvote 0

Sarah K

New Member
Joined
Nov 26, 2008
Messages
24
Greg,
you've got the idea of what I want...can you use my example and show me how to look up the cell value in a completely different workbook?
Thanks a million!
 
Upvote 0

Sarah K

New Member
Joined
Nov 26, 2008
Messages
24
Like this:
application.vlookup(range(cells(i,2)),workbook(x).sheets(y).range("E:H"),2,false)
??
Says I have a 'Compile error: expected: =
I like your parents/children thing :p
 
Upvote 0

Forum statistics

Threads
1,191,366
Messages
5,986,244
Members
440,012
Latest member
StumpedGump1987

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
Top