Skip to main content
SheetTidy

Merge two Excel sheets by a common column

Pull matching columns from a lookup sheet into your main sheet by ID, without writing a single VLOOKUP formula.

  1. 1
  2. 2
  3. 3
  4. 4

Drop your Excel or CSV files here

Add the main sheet and the lookup sheet, together or one at a time.

XLSX, XLSM, XLS, ODS, CSV, TSV or JSON

Your file never leaves your device

How to use this tool

  1. Step 1: Add the main sheet and the lookup sheet

    Drop two files, or one workbook and tick both of its sheets. The main sheet keeps all its rows; the lookup sheet supplies the extra columns. Use Swap files if they are the wrong way round.

  2. Step 2: Confirm the key columns

    By default the tool picks the first column whose name appears in both sheets. If the names differ, such as "Cust ID" and "Customer ID", choose the matching column in the lookup sheet yourself.

  3. Step 3: Choose the columns to bring across

    Tick the lookup columns you want, such as Name and City, or leave them all unticked to add every column except the key.

  4. Step 4: Decide what to do with unmatched rows

    Keep them with the new columns left empty, or leave them out. The summary names the keys that found no match so you can follow them up.

  5. Step 5: Download the merged file

    Save the result in the same format as your main file. If you left unmatched rows out, you can download them separately with Download removed rows.

How to merge sheets by a column manually in Excel

Bringing columns from one table into another based on a shared ID is one of the most common jobs in Excel. There are three main ways to do it, and each has habits that trip people up.

VLOOKUP

With orders on one sheet and customer details on a sheet called Customers, put this next to the first order:

=VLOOKUP(A2,Customers!$A:$D,2,FALSE)

It looks up the value in A2 in the first column of the Customers range and returns the second column, which might be the name. Some things to watch:

  • The last argument must be FALSE for an exact match. Leaving it out means an approximate match, which quietly returns the wrong customer on unsorted data.
  • The key must be the first column of the lookup range. If Customer ID is in column C, you need to rearrange the sheet or use another formula.
  • You need one formula per column: change the 2 to 3 for City, 4 for Email, and fill each down.
  • VLOOKUP ignores capital letters, but it does not forgive a trailing space or a number stored as text. “C-101 “ and “C-101” do not match, nor do 123 and “123”, so you get #N/A even though the IDs look the same.

XLOOKUP and INDEX/MATCH

Excel for Microsoft 365 and Excel 2021 offer =XLOOKUP(A2,Customers!A:A,Customers!B:B,"Not found"). The key can be in any column, the match is exact by default, and the fourth argument replaces #N/A with your own text. In older versions, =INDEX(Customers!B:B,MATCH(A2,Customers!A:A,0)) gives the same flexibility. Both still fail on stray spaces and on numbers stored as text.

Power Query

For larger or repeated jobs, load both tables into Power Query, then choose Home › Merge Queries. Pick the main table and the lookup table, click the matching column in each, and choose a Join Kind: Left Outer keeps every row of the main table, Inner keeps only rows that match. Click OK, then use the expand button on the new column header to pick the fields to bring in. Be aware that Power Query matches text case-sensitively by default, so “c-101” will not find “C-101”.

Whichever formula method you use, finish by selecting the new columns and choosing Paste Special › Values, otherwise the results break when the lookup sheet is moved or deleted.

When this tool helps

Orders and customers. Your shop exports orders with only a customer ID. Bring in the name, city and email from the customer list so the sheet is ready for a courier or a mailing.

Stock lists and prices. The warehouse sheet has SKUs and quantities; the price list sits elsewhere. Join on SKU to value your stock without copying prices by hand.

Attendance and departments. HR gives you an attendance export with employee codes. Pull in each person’s department and manager from the staff list to build a report per team.

Invoices and tax details. Add each customer’s GST number to an invoice register by matching on customer code, so the accountant gets one complete sheet.

What the tool does differently

  • It forgives the usual mismatches. Extra spaces in keys are always ignored, capital letters are ignored by default, and numbers match their text versions. These are the reasons most lookups fail.
  • It brings every column in one step. No column numbers to count and no formulas to fill down.
  • It tells you what did not match. With the sample file the summary reads: “Matched 3 of 4 rows on Customer ID and added Name, City and Email from Customers. 1 row had no match and was left blank: C-109.” The order for “c-101 “ matched despite its lower-case letter and trailing space.
  • It never overwrites your data. New columns go at the end, and a clashing name gets “ (2)” added.
  • It gives plain values. The download holds values, not formulas, in the same format as your main file.

Before you merge

Check that the lookup sheet has one row per ID. If the same customer appears twice with different cities, only the first is used, so remove duplicates in the lookup sheet first if you are unsure which is correct. And if many rows come back unmatched, look at the listed keys: a different prefix or a missing leading zero often explains it.

Think about which sheet should be the main one. The main sheet decides how many rows you end up with and in what order, so it is usually the list you are working from, such as this month’s orders. The lookup sheet is the reference list, such as all customers. If you only want orders from known customers, choose “Leave them out” for rows without a match, then download the removed rows to see which orders need a customer record added.

Frequently asked questions

How is this different from VLOOKUP?

It does the same job for every column at once. There are no formulas to copy down, the key does not have to be the first column, and a missing match gives an empty cell rather than #N/A.

Why do my VLOOKUPs return #N/A when the IDs look identical?

Usually a hidden space at the end of one ID, or a number stored as text in one sheet and as a number in the other. This tool ignores extra spaces in keys and treats 123 and "123" as the same, so those rows match.

Does capitalisation matter when matching keys?

Not by default, so "c-101" matches "C-101". If your codes are case-sensitive, untick Ignore capital letters in keys under More options.

What if an ID appears more than once in the lookup sheet?

The first matching row is used, just as VLOOKUP would. The summary tells you how many repeated keys it found, so you can check whether they hold different details.

What if the main sheet already has a column with the same name?

Your existing column is left alone and the new one is added at the end with " (2)" after its name, for example "City (2)", so nothing is overwritten.

Can the two sheets be in the same workbook?

Yes. Open the workbook once and tick both sheets. If the main sheet and the lookup sheet end up the wrong way round, click Swap files.