How to merge two Excel files using a common column

Updated 30 October 2026

One file has your customers. Another has their orders, or a price list has codes and a stock report has the same codes with quantities. You want one table with everything side by side, lined up by the column they share. That is a merge (a "join" in database terms), and Excel can do it in two ways: a lookup formula, or Power Query. If you would rather not write either, you can do it in your browser.

Do you need to join the files or stack them?

"Merge" means two different jobs. Joining lines up rows from both files by a shared value, adding columns: customer ID 1042 gets its email from one file and its order total from the other. Stacking puts one file's rows under the other's, for example January's sales above February's. This guide is about joining. To stack, see the FAQ at the end.

What do you need before merging?

rows match on the shared key column = equal keys
  • A key column in both files whose values identify a row: an ID, an email address, a product code. Names make poor keys because people share them.
  • The same kind of value on both sides. 1042 as a number does not match "1042" as text.
  • No stray spaces. "ACME " does not match "ACME".
  • Unique keys in the file you look up from. If a key appears twice, a lookup only uses the first one.

Most failed merges come from the second and third points. VLOOKUP not working? shows how to spot and fix them.

How do you merge two Excel files with XLOOKUP?

  1. Open both files and copy the second table into a new sheet of the first workbook. Call it Orders. (You can look up into another open workbook, but one workbook is easier to keep working.)
  2. In your main sheet, add a heading for the column you want to bring across, say Total in column D.
  3. In D2, type the lookup. Here the key is in column A of both sheets and the total is in column C of Orders:
=XLOOKUP(A2,Orders!$A$2:$A$500,Orders!$C$2:$C$500,"Not found")
  • A2: lookup_value
  • Orders!$A$2:$A$500: lookup_array
  • Orders!$C$2:$C$500: return_array
  • "Not found": if_not_found
  1. Double-click the fill handle (the small square at the bottom right of the cell) to copy the formula down. The $ signs keep the ranges fixed while A2 moves down.
  2. Need several columns? Make the return range wider and they spill across in one go:
=XLOOKUP(A2,Orders!$A$2:$A$500,Orders!$B$2:$D$500,"Not found")

To freeze the result, copy the merged columns and use Paste Special, Values. In Excel 2019 or earlier, use VLOOKUP instead; the key must then be the first column of the range:

=IFNA(VLOOKUP(A2,Orders!$A$2:$D$500,3,FALSE),"Not found")

XLOOKUP vs VLOOKUP explains the differences. To practise the formula, try XLOOKUP basics and Looking up from another sheet.

How do you merge on two columns, like first and last name?

Join the key columns together on both sides and look that up. The "|" separator stops "Ann" & "abel" matching "Anna" & "bel":

=XLOOKUP(A2&"|"&B2,Orders!$A$2:$A$500&"|"&Orders!$B$2:$B$500,Orders!$D$2:$D$500,"Not found")

This works in Excel 365 and 2021 or later. In older versions, add a helper column that joins the keys in each table, and look up that column.

How do you merge two Excel files with Power Query?

Power Query is built into Excel 2016 and later and is the better choice for big files or a merge you repeat every month:

  1. Go to Data, Get Data, From File, From Workbook, pick the first file and load its table as a query. Do the same for the second file.
  2. Select the first query and choose Home, Merge Queries.
  3. Pick the second table, click the key column in each (hold Ctrl to choose two columns), and choose a join kind.
  4. Click the expand icon on the new column header, tick the columns you want, then Close & Load.

The join kind decides which rows you get back:

Join kindYou getSame as
Left OuterEvery row of the first file, with matches filled inA lookup formula copied down
InnerOnly rows found in both filesFiltering out the "Not found" rows
Left AntiRows of the first file with no matchA list of what's missing
Full OuterEvery row from both filesBoth lookups plus both missing lists

Next month, drop the new files in the same place and click Refresh.

What happens to rows that don't match?

With the formulas above they show "Not found", which is what you want: the rows stay lined up with your original list, and you can see exactly which ones need attention. Before assuming the record really is missing, check the usual suspects: numbers stored as text, trailing spaces and leading zeros (00421 vs 421). To see the missing rows from the other side too, compare the files in both directions as shown in how to compare two Excel sheets.

What about duplicate keys?

A lookup formula returns the first match and ignores the rest. Power Query returns every match, so a customer with three orders becomes three rows. Count how often each key appears with =COUNTIF(Orders!$A$2:$A$500,A2) before you merge, so neither result surprises you.

How can you merge two files without formulas?

Open Lookup & Merge, drop in both files (.xlsx, .xls or .csv), choose the column to match on and the columns to bring back. You can:

  • keep every row, keep only matches, or list what's missing from each side (the Left Outer, Inner and Anti joins above);
  • match on two or more columns at once, such as first name and last name;
  • ignore case, extra spaces, punctuation and leading zeros, or turn on fuzzy matching for near-misses like "Acme Ltd" and "ACME Limited";
  • pick the first, last or every match when a key is duplicated.

Every row that doesn't match tells you why, and the result downloads as .xlsx or .csv. It also shows the XLOOKUP formula for your exact columns, so you can repeat the merge in Excel next time. The files are read in your browser and never uploaded. Need to tidy a file before or after merging? Load it into the Table Workspace to remove duplicates, trim spaces or reorder columns.

Revision Q&A

(click a question) Guide Q&A
Q1: Can I merge two Excel files if the matching columns have different names? expand_more

Yes. Neither XLOOKUP nor Power Query cares about the header names, only about the values in the cells. "Customer ID" in one file can match "Cust_No" in the other as long as the IDs themselves are the same.

Q2: What if the two files have a different number of rows? expand_more

That is normal. A lookup keeps every row of your main file and fills in the matching details. Rows in the second file that nothing points at are simply left out, and you can list them separately with a left anti join or the "What's missing" option.

Q3: How do I merge two Excel files and remove duplicates? expand_more

Remove duplicate keys from the lookup file first, otherwise each lookup only uses the first match. In Excel use Data, Remove Duplicates on the key column. Without Excel, the Remove duplicates step in the Table Workspace does the same.

Q4: How do I merge two Excel files into one workbook without matching anything? expand_more

That is stacking, not joining. Open both files, right-click the sheet tab, choose Move or Copy and pick the other workbook. To stack rows from files with the same columns, use Power Query's Append Queries.

Q5: Is it safe to merge confidential spreadsheets online? expand_more

Only with a tool that does not upload them. Lookup & Merge on this site runs entirely in your browser: the files are read on your computer and never sent to a server.

Q6: How do I do the same merge in Google Sheets? expand_more

Put both tables in one spreadsheet (IMPORTRANGE can pull a range from another spreadsheet) and use XLOOKUP or VLOOKUP exactly as in Excel. Google Sheets supports both.

Q7: How do I merge two Excel files in Python? expand_more

With pandas: read both files with pd.read_excel, then pd.merge(left, right, on="ID", how="left"). how="left" keeps every row of the first file, like a lookup; how="inner" keeps only matches.

Know someone fighting with a spreadsheet? Send them this page.