Microsoft Query allows you to match data from one sheet in a Microsoft Office Excel 2010 spreadsheet to data in another sheet and create a new sheet that combines the data from both source sheets.
- Both sheets must have column headings.
- Both sheets must be in the same workbook.
- Both sheets must have named ranges for the data.
- Both sheets must have the common column formatted the same way.
- Highlight the columns that contain your data.
- Go to the Formula tab.
- In the Defined Names group, select Define Name.
- Enter a name.
- Repeat for sheet 2.
If you are matching on BUID, then BUID in both files must both be formatted as General. If BUID is formatted as text, then save a copy as a CSV and import the CSV into a new sheet in the other workbook.
- Go to File, Save As, Save As CSV (Comma Separated Values). Save and close the CSV.
- Import the CSV into the other sheet.
- Open the correctly formatted workbook.
- Select the second sheet.
- Select the Data tab.
- In the Get External Data group, select From Text. Find the CSV and import it into the second sheet.
- Save the workbook.
The text you are matching must be in the same case in both sheets. If the case is not the same, use the formula to change case and put the data in a new column.
Begin the Query
- Go to sheet 3 in your workbook (sheets 1 and 2 contain the source data).
- Go to the Data tab.
- In the Get External Data group, select From Other Sources.
- Select From Microsoft Query. Select Excel Files. Select the file you are currently using.
- In the Query Wizard, in Available tables and columns, select the named range on sheet 1 and use the arrow to move it to the Columns in your query box. Repeat with the named range on sheet 2. Press Next.
- Microsoft Query will display a warning:
The Query Wizard cannot continue because it can not join the tables in your query. You must join the tables manually in Microsoft Query by dragging the fields to join between the tables. Press OK.
- Click on the common heading name in the first box. Drag and drop it onto the matching heading name in the second box. A small line will link the two headings.
- Double click on the line. Select the appropriate type of join
- Inner join (Option 1): The query will return only rows that appear in both sheets. Any rows that only appear in sheet 1 or sheet 2 will not display on sheet 3.
- Outer join (Option 2 or 3): The query will return all rows for sheet 1 and matching entries for sheet 2 OR the query will return all rows for sheet 2 and matching entries for sheet 1.
- Click Add. Click Close.
- Click the Return Data button. Save as a Table in the Existing Worksheet. Sort the worksheet by an appropriate heading.
- Save the file.
For additional information or assistance, please contact the Tech Desk at 570.577.7777 or firstname.lastname@example.org.
Keywords: formula, match, query