Suggestions on how to compile two sheets into one using unique values

spectraflame

Well-known Member
Joined
Dec 18, 2002
Messages
830
Office Version
  1. 365
Platform
  1. Windows
I need to combine data from two sheets into one based on employee number. Sheet 1 has all of the data in a single row for each employee. Sheet 2 has all of the employees dependent related information on multiple rows. Both sheets have a unique number for each employee. The number of related employee records from Sheet 2 varies based on the number of dependents. There are 4 specific fields for each record from Sheet 2 that need to be combined with the rows in Sheet 1. Does anyone have suggestions on a way to combine this other than manually copying the data from one to the other?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
you could use filter , maybe with a vstack
but i'm not 100% sure how you want to have the combined data

sheet1 is 1 row per ID
sheet2 is multiple rows per ID

if its only 4 fields then a lookup would do

assuming your unique id is in say column A and you wanted the results in column W,X,Y & Z on sheet1 the 4 fields from sheet2
and on sheet2 the ID is also in column A say , and in sheet2 the columns with the 4 lots of data are in E,F,G & H

In Sheet1 column W W2
=index(sheet2!E$2:E$10000, match($A2, sheet2!$A$2:$A$1000,0))
and copy across and down

so change
sheet2!E$2:E$10000,
to however many rows you need , doesnt matter if its a lot more ,as long as you cover all the possible rows
and then change

E to whatever column the data you want is in
 
Upvote 0
Sheet1 headings range is A2:Y2. Data A3:Y25. Unique number is in Column G.
Sheet2 headings range is A2:AR2. Data A3:AR20..Unique number is in Column J.
In Sheet2
In AS2
Excel Formula:
=IFERROR(INDEX(Sheet1!$A$2:$Y$2,SMALL(IF(COUNTIF($A$2:$AR$2,Sheet1!$A$2:$Y$2)=0,COLUMN(Sheet1!$A$2:$Y$2),""),COLUMNS($A1:A1))),"")
Drag across till blank result is seen.
In AS3
Excel Formula:
=IFERROR(INDEX(Sheet1!$A$3:$Y$25,MATCH($J3:$J20,Sheet1!$G$3:$G$25,0),MATCH(AS$2,Sheet1!$A$2:$Y$2,0)),"")
Drag across .
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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
Back
Top