Solved

merging data from 2 sheets based on a join value

Posted on 2016-09-22
4
34 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
4 Comments
 
LVL 32

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 28

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 13

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now