Solved

merging data from 2 sheets based on a join value

Posted on 2016-09-22
4
55 Views
Last Modified: 2016-10-20
I have an xlsx with 2 sheets, in the first sheet, customer data is in a row by row format, i.e

Custreference forename surname address 1 address 2 etc
12345 EE user 123 street london

At the end of sheet 1 are 3 blank columns (phone, mobile, email), and I need to populate them with data from sheet 2

In sheet 2 are 3 columns

Custreference type value
e.g.
12345 phone 999888
12345 mobile 777666
12345 email op@ee.com

The only way to join the records is via the customer reference field which is on both sheets. What i need really is 3 formulas in the 3 columns in sheet 1, to check all values of sheet 2, and for example in the phone column, compare all  the rows in sheet 2, where type = phone, and reference matches from both sheets, to populate the phone column with the value for that reference in sheet 2.

Likewise for the mobile column, check all rows in sheet 2 where reference matches, and type = mobile, populate the mobile column in sheet 1 with the mobile value in sheet 2 for that reference.
0
Comment
Question by:pma111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 33

Accepted Solution

by:
Rob Henson earned 250 total points
ID: 41810529
In sheet 2 use the CONCATENATE function to combine the cust ref with type:

=CONCATENATE(A2,"_",B2)  gives "12345_phone"

Then in sheet 1 use a vlookup on a similarly concatenated value:

=VLOOKUP(CONCATENATE($A2,"_",F$1),Sheet2!$A:$D,4,False)   where A2 is CustRef and F1 is type header

If you upload a sample, it can be put in place.

Thanks
Rob H
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41810533
Please upload a sample workbook to work with.
0
 
LVL 27

Assisted Solution

by:Glenn Ray
Glenn Ray earned 250 total points
ID: 41811563
Rob's recommendation is the easiest - add a concatenated Key Field that helps identify the records.  You can also combine the fields like so:
Key Field:  =A2&B2

Adding a delimiting character (like an underscore) helps readability, but isn't necessary to make the VLOOKUP work.

Usually these are set up as temporary columns and are quick and relatively non-invasive on your data.  However, if you really want to retrieve the data using multiple variables, there is a more-complex method that doesn't involve any table manipulation.

Given your data construction in Sheet2, the values can be retrieved with this formulas:
=IFERROR(INDEX(Data!$C$2:$C$1000,SUMPRODUCT(--($A2=Data!$A$2:$A$1000),--(I$1=Data!$B$2:$B$1000),ROW($2:$1000))-1),"")

This presumes that:
1) the Custreference is in column A (like in your example)
2) the columns for "phone", "mobile", and "email" are in columns I, J, and K in Sheet1
3) the column headers in I1, J1, and K1 are "phone", "mobile", and "email"
4) there is no more than 1000 rows of data in Sheet2

The Sheet2 data can be in any order and doesn't have to have values for all Custreference codes. The formula is the same in all three columns; just copy across and down.  See the example workbook.
EE-Q_28971612.xlsx
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41851709
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Rob Henson (https:#a41810529)
-- Glenn Ray (https:#a41811563)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
excel 2013 keeps 4 30
Copy Picture from one workbook to newly created workbook 12 39
sort time order 10 45
LOOK FOR 22 28
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question