Reputation: 5044
I have two Excel sheets. First one is like this:
folk_id name first_name town_name
001 blog joe alamo
002 folk james brisbane
003 paco yatan barcelona
Second one is like this:
folk_id music_instrument color
001 banjo blue
001 guitar green
001 piano yellow
002 harmonica grey
003 harpsichord red
003 violin orange
003 bass fuschia
Results would be like this (either in the same sheet or a different one):
folk_id name first_name town_name music_instrument color
001 blog joe alamo banjo blue
001 blog joe alamo guitar green
001 blog joe alamo piano yellow
002 folk james brisbane harmonica grey
003 paco yatan barcelona harpsichord red
003 paco yatan barcelona violin orange
003 paco yatan barcelona bass fuschia
I've tried with VLOOKUP
and INDEX
but I'm bit confused on how to do it.
I'm looking for a formula and not VBA.
Upvotes: 1
Views: 131
Reputation: 59440
Copy second sheet, insert three columns between folk_id
and music_instrument
(assuming four columns in the source, might actually be only three) then use a lookup function to populate the added columns. Assuming folk_id
is then in A1, in B1:
=VLOOKUP($A1,Sheet1!$A$1:$D$4,COLUMN(),0)
copy across and down to suit.
Upvotes: 3
Reputation: 5958
This answer covers how to do this on a third sheet. For simplicity lets call each sheet Sheet1, Sheet2, Sheet3
Sheet1 and Sheet2 contain your current data.
The first step is to make a reference in Sheet3 that copies the entire column of folk_id
. Because it seems Sheet2
contains the larger amount of folk_id
and Sheet1 contains the unique values of folk_id
you need to copy Sheet2
. To do this just simply call =Sheet2!A2
starting in A2
of Sheet3, and just auto fill down.
Now for each column in where data lies in Sheet1 we will perform the index and match. While for data that is in sheet2 you only need to have reference calls.
=INDEX(Sheet1!B:B,MATCH(A2,Sheet1!A:A,0))
starting in cell B2
and autofill down.=INDEX(Sheet1!C:C,MATCH(A2,Sheet1!A:A,0))
starting in cell C2
and autofill down.=INDEX(Sheet1!D:D,MATCH(A2,Sheet1!A:A,0))
starting in cell D2
and autofill down.=Sheet2!B2
starting in cell E2
and autofill down.=Sheet2!C2
starting in cell F2
and autofill down. Upvotes: 0