Compare Two Excel Sheets and Highlight the Differences
By ExcelReady TeamUpdated 5 min read
The short answer
To compare two sheets in Excel cell by cell, add a third sheet and enter =IF(Old!A1<>New!A1,"Different","") in A1, then fill it across and down. To highlight the changes instead, use a conditional formatting rule such as =A1<>New!A1. If rows can be in a different order, match them by ID with COUNTIF or XLOOKUP.
Key takeaways
- A cell-by-cell IF formula on a third sheet shows exactly which cells differ, and what each sheet holds.
- A conditional formatting rule like =A1<>New!A1 colors the changed cells on the sheet itself.
- Row-by-row checks only work when both sheets list the same records in the same order.
- When rows are added, removed or sorted, match on an ID column with COUNTIF and XLOOKUP instead.
On this page+
To compare two sheets in Excel, you either check them cell by cell (when both have the same layout and order) or by ID (when rows may have moved, been added or been removed). A simple IF formula, a conditional formatting rule and COUNTIF cover both cases, in any version of Excel. This guide is for anyone who has an old and a new version of a report and needs to know exactly what changed.
Which method should you use?#
The right method depends on whether the rows still line up:
| Situation | Best method | What you get |
|---|---|---|
| Same layout, same row order | IF formula on a third sheet | A grid showing every changed cell |
| Same layout, want to see changes in place | Conditional formatting rule | Changed cells colored on the sheet |
| Rows added, removed or sorted | COUNTIF and XLOOKUP on an ID column | Missing, new and changed records |
| Just want to look | View Side by Side | Both sheets scrolling together |
All the examples use two sheets in one workbook, named Old and New, each with invoice IDs in column A and amounts in column B:
| Row | Old: ID | Old: Amount | New: ID | New: Amount |
|---|---|---|---|---|
| 2 | INV-101 | 250 | INV-101 | 250 |
| 3 | INV-102 | 480 | INV-102 | 520 |
| 4 | INV-103 | 125 | INV-104 | 900 |
| 5 | INV-104 | 900 | INV-105 | 310 |
| 6 | INV-105 | 310 | INV-106 | 75 |
Between the two versions, INV-102 changed from 480 to 520, INV-103 was removed, and INV-106 was added.
Compare two sheets cell by cell with IF#
A comparison sheet checks each cell against the same cell on the other sheet. Add a new sheet (Windows: Shift+F11; Mac: Fn+Shift+F11, or click the + next to the tabs), then type this in A1:
=IF(Old!A1<>New!A1,"Old: "&Old!A1&" | New: "&New!A1,"")Fill it right and down to cover the whole data area. A cell stays blank when both sheets match, and shows both values when they don't. <> means "not equal to"; the IF function guide explains the three parts of IF.
If you only want TRUE or FALSE, a bare comparison is enough: =Old!B3=New!B3 returns FALSE here, because 480 is not 520. The lesson on TRUE, FALSE and comparisons covers how these work. Comparisons with = ignore capitals; the guide to comparing two cells shows how to use EXACT when case matters.
If the sheet names contain spaces, Excel needs quotes around them: ='Old data'!A1.
Highlight differences with conditional formatting#
Conditional formatting colors cells that meet a rule, so you see changes right on the sheet:
- On the Old sheet, select the data, for example A1:B6, starting from A1.
- Go to Home > Conditional Formatting > New Rule.
- Choose Use a formula to determine which cells to format.
- Enter
=A1<>New!A1and click Format to pick a fill color. - Click OK.
Write the rule for the top-left cell of your selection, with no $ signs. Excel then moves the reference for each cell, so B3 checks against New!B3. The guide to conditional formatting with a formula explains why the $ matters, and the conditional formatting lesson lets you try formula rules hands-on. Rules that refer to another sheet work in Excel 2010 and later.
Why row-by-row comparison can mislead you#
Cell-by-cell checks assume the same record sits on the same row in both sheets. In our example, that's only true for rows 2 and 3. Because INV-103 was removed, everything below moved up one row.
A row-by-row check of the amounts flags 4 differences (rows 3 to 6), but only one amount actually changed. The others are the same invoices sitting on different rows. So use cell-by-cell methods only when you're sure the rows line up, such as two copies of a fixed template.
Compare rows by ID when the order changes#
When rows can move, match them on a column that uniquely identifies each record, such as an invoice ID or employee number.
Find records missing from the new sheet. On the Old sheet, in C2:
=IF(COUNTIF(New!$A$2:$A$6,A2)=0,"Missing","Found")COUNTIF counts how many times the ID appears in the New sheet. Zero means it's gone. Fill it down and INV-103 shows Missing. The COUNTIF function guide covers the syntax. Do the same on the New sheet against Old's IDs to find new records: INV-106 is the only one.
Find changed values. In Excel 2021 or Microsoft 365, bring back the new amount with XLOOKUP, then compare. In D2 on the Old sheet:
=XLOOKUP(A2,New!$A$2:$A$6,New!$B$2:$B$6,"Missing")For INV-102 this returns 520. Then =IF(D2="Missing","Missing",IF(D2=B2,"Same","Changed")) labels each row. In older Excel, use VLOOKUP with FALSE in place of XLOOKUP. The guide to comparing two lists shows more ways to find matches and gaps, and the guide to finding duplicates in two columns covers the overlap.
Lock the lookup ranges with $ before you fill down, or they'll slide off the data.
Look at two sheets side by side#
Sometimes you just want to scroll through both. On Windows:
- Go to View > New Window. A second window of the same workbook opens.
- In the new window, click the other sheet's tab.
- Go to View > View Side by Side. Synchronous Scrolling turns on, so both scroll together.
On a Mac, open the second window from Window > New Window and arrange the two windows next to each other.
Some Windows editions of Office also include Spreadsheet Compare, a separate program that lists every difference between two workbooks, including formulas and formatting. If you don't see it, the formula methods above do the job in any edition.
Practise it#
Most sheet comparisons come down to COUNTIF and a comparison inside IF. Practise COUNTIF in a live spreadsheet: you type the formula and it checks it instantly. Then learn TRUE, FALSE and comparisons and color cells with formula rules. Try the exercise on this page first. If you also need to spot repeats within one sheet, see how to highlight duplicates.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Old invoices are in A2:B6 and the new list is in D2:E6. Is INV-103 (cell A4) still in the new list? Click G4 and use IF with COUNTIF on D2:D6: show Missing if it isn't found, otherwise Found.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Old amount | New amount | ||||||
| 2 | ||||||||
| 3 | ||||||||
| 4 | ||||||||
| 5 | ||||||||
| 6 | ||||||||
| 7 | ||||||||
| 8 | ||||||||
| 9 |
Tip: COUNTIF(D2:D6,A4) counts how often INV-103 appears in the new list. If that count is 0, it's missing.
Practise this in a lesson
Frequently asked questions
How do I compare two Excel sheets for differences?
Add a new sheet, type =IF(Sheet1!A1<>Sheet2!A1,"Different","") in A1, and fill it across and down to cover the data. Every cell that shows Different has changed between the two sheets.
How do I highlight differences between two sheets?
Select the data on the first sheet, choose Home > Conditional Formatting > New Rule > Use a formula, and enter =A1<>Sheet2!A1, with A1 being the top-left cell you selected. Pick a fill color and click OK.
How do I compare two sheets when the rows are in a different order?
Match on a unique ID instead of the row position. =COUNTIF(Sheet2!A:A,A2)=0 shows TRUE for IDs missing from the second sheet, and XLOOKUP brings back the matching value so you can compare it.
Does Excel have a built-in tool to compare two files?
Some Windows editions of Office include Spreadsheet Compare, which compares two workbooks and lists every difference. If you don't have it, formulas and conditional formatting do the same job inside Excel.
Is comparing sheets in Excel case-sensitive?
No. The = and <> operators ignore capitals, so Apple and APPLE count as the same. Use EXACT, such as =NOT(EXACT(Sheet1!A1,Sheet2!A1)), when capitals matter.