vlookup function

R

Ranjit kurian

I have two sheets(sheet1 and sheet2) i would like to pull column B from
sheet2 to sheet1, the column A of both the sheets are similar, could someone
tell me whts wrong in my below code.

Range("A2").Select
Lastrow = Range("A65536").End(xlUp).Row
'Range("B2:B" & Lastrow).Formula = "=VLOOKUP(C[1],'sheet2!C1:C2,2,0)"

question:

Sheet1
Name LastName
ARUN 'vlookup answer '

Sheet2
Name LastName
ARUN AR

Answer

Sheet1
Name LastName
ARUN AR

Sheet2
Name LastName
ARUN AR
 
J

Jim Cone

Before you try adding a formula with code, test it on the worksheet.
If it doesn't work on the sheet, it won't work with code...

C[1] should be C1

You only show one column for the lookup but you specify 2 columns?
Change the 2 to 1
--
Jim Cone
Portland, Oregon USA



"Ranjit kurian" <
(e-mail address removed)>
wrote in message
I have two sheets(sheet1 and sheet2) i would like to pull column B from
sheet2 to sheet1, the column A of both the sheets are similar,
could someone tell me whts wrong in my below code.

Range("A2").Select
Lastrow = Range("A65536").End(xlUp).Row
'Range("B2:B" & Lastrow).Formula = "=VLOOKUP(C[1],'sheet2!C1:C2,2,0)"

question:
Sheet1
Name LastName
ARUN 'vlookup answer '

Sheet2
Name LastName
ARUN AR

Answer
Sheet1
Name LastName
ARUN AR

Sheet2
Name LastName
ARUN AR
 
S

Simon Lloyd

Firstly your code should look like thi
Code
-------------------
Range("A2").Selec
Lastrow = Range("A65536").End(xlUp).Ro
Range("B2:B" & Lastrow).Formula = "=VLOOKUP(C1,sheet2!C1:C2,2,0)
-------------------
Secondly, your Vlookup range only spans 1 column but you have asked i
to return the value from the second column, it should look like thi
*VLOOKUP(C1,sheet2!C1:D2,2,0)* but i'm not entirely sure what you ar
after
I have two sheets(sheet1 and sheet2) i would like to pull column B fro
sheet2 to sheet1, the column A of both the sheets are similar, coul
someon
tell me whts wrong in my below code
Code
-------------------Range("A2").Selec
Lastrow = Range("A65536").End(xlUp).Ro
'Range("B2:B" & Lastrow).Formula = "=VLOOKUP(C[1],'sheet2!C1:C2,2,0)
-------------------question

Sheet
Name LastNam
ARUN 'vlookup answer

Sheet
Name LastNam
ARUN A

Answe

Sheet
Name LastNam
ARUN A

Sheet
Name LastNam
ARUN A

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top