Solved

merging data from 2 sheets based on a join value

Posted on 2016-09-22
4
57 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

Independent Software Vendors: 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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

726 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