Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default vlookup function

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default vlookup function

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" <

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vlookup function


Firstly your code should look like this
Code:
--------------------
Range("A2").Select
Lastrow = Range("A65536").End(xlUp).Row
Range("B2:B" & Lastrow).Formula = "=VLOOKUP(C1,sheet2!C1:C2,2,0)"
--------------------
Secondly, your Vlookup range only spans 1 column but you have asked it
to return the value from the second column, it should look like this
*VLOOKUP(C1,sheet2!C1:D2,2,0)* but i'm not entirely sure what you are
after!

Ranjit kurian;231976 Wrote:
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.


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



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=64772

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
How to combine Combo Box function with Vlookup function KH Excel Worksheet Functions 2 April 5th 10 01:24 PM
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
HOW DO I NEST THE VLOOKUP FUNCTION WITH THE LEFT FUNCTION CHAIM Excel Worksheet Functions 1 July 27th 05 09:10 PM
how do I write a vlookup function within an iserror function so t. JBLeeds Excel Worksheet Functions 2 March 16th 05 10:30 AM
I want to use Vlookup function and AND function in a single formu. prakash Excel Worksheet Functions 3 January 25th 05 07:11 AM


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