Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-Insert values to new column from another worksheet - Excel 2007

Status
Not open for further replies.
Feb 4, 2002
792
0
0
GB
Sorry if this has been dealt with before - my attempts at creating a suitable search phrase to fins info on this failed.

Right - I have 2 worksheets. They have common values in the first column. The 2nd worksheet simply has this common code and some product codes in the 2nd column.

Example:

Col 1 Col 2
1 sdf98hjk
2 adf34ghj
3 rlk29mbn

The 1st sheet has details about products, but some rows are the same product, but with different values. I need a new column on this first sheet to display product codes against each row that relates to that product.

Example:

Col 1 Col 2 Col 3
1 Stuff More Stuff
1 Stuff Other Stuff
1 Things More Things
2 Stuff More Stuff
2 Stuff Other Stuff Still
3 Stuff Other Stuff

The result I am looking for is as follows:

Col 1 Col 2 Col 3 Col 4 (new column)
1 Stuff More Stuff sdf98hjk
1 Stuff Other Stuff sdf98hjk
1 Things More Things sdf98hjk
2 Stuff More Stuff adf34ghj
2 Stuff Other Stuff Still adf34ghj
3 Stuff Other Stuff rlk29mbn

I tried using =INDEX(Sheet2!B:B,MATCH(Sheet2!A:A,Features!A:A,0))

But this just gives results that draw codes from row 10 of the 2nd sheet for row 2/col 4 of the 1st sheet, or row 17, etc. (seems to be random - not sure).

If anyone can help with a formula, I would be most grateful!

For example is there a comparison so I can check if value in first column of sheet 1 is same as sheet 2, then insert value from col 2 of sheet 2 into col 4 of sheet 1. BTW - I tried an if statement first, but it got complex. The INDEX MATCH above gave better results more concisely (i.e. it is getting values from the right column on sheet 2, just not the right values), but still incorrect.

Perhaps VLookup?

Will
[morning]
 
Of course... I post the question, then manage to find the answer on my own!!

=VLOOKUP(A2,Sheet2!$A$2:$B$15581,2,FALSE)

Will
[morning]
 

hi,

You were on the right track. I prefer and almost always use INDEX & MATCH...
[tt]
=INDEX(Sheet2!B:B,MATCH(A2,Sheet2!A:A,0))
as you posted...
=VLOOKUP(A2,Sheet2!$A$2:$B$15581,2,FALSE)
[/tt]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thx - I always want to know what I'm doing wrong in first place... fits the bill perfectly! win-win! ;) Or rather 2 wins for me... :)

Will
[morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top