
How to Remove Duplicates in Excel by Key (and Keep the Right Row)
The fast Excel way, and the harder one the button cannot do: dedupe by a key column, keep the most-complete row, and get an audited removed count.
Data Analysis — Buyer’s guide · 2026
Compare two versions of a spreadsheet and see what changed — View Side by Side, conditional formatting, the Spreadsheet Compare add-in, and a keyed way to show added, removed, and changed rows even when the rows move.
Quick answer — how to compare two Excel files
To compare two Excel files and highlight the differences, put both versions in one workbook and use conditional formatting: select your data, add a New Rule with the formula =A2<>OtherSheet!A2, and Excel colors every cell that changed. That works while the rows still line up. If rows were added, removed, or reordered, compare by a key column instead, because a position-based highlight flags every row below the change as different. On Windows with Office Professional Plus or Microsoft 365 Apps for enterprise, the built-in Spreadsheet Compare tool produces a full cell-by-cell report; and Anomaly can return a keyed, highlighted, downloadable comparison from one plain-language request.
When people say "compare two Excel files," they usually mean two versions of the same spreadsheet — last month's and this month's, yours and a colleague's, the one you sent and the one that came back — and they want to see what changed: which values moved, which rows were added, and which were removed. That is a different job from comparing two separate lists to find which entries are missing from one of them; if that's what you need, comparing two lists in Excel to find missing records is its own method. This guide is about the version-comparison job: highlighting the differences between two workbooks, and getting a result you can hand to someone else.
There's a native way that's fine for a quick look, a more careful way that survives rows moving around, and a dedicated Microsoft tool that only some Excel editions have. The first method has a specific trap: an inserted row can create position-based mismatches. A highlight that compares cells by position looks perfect until a row moves, and then it lights up half the sheet in false differences. Here's each method and when to trust it.
The simplest way to see two files together is View Side by Side. Open both workbooks, go to the View tab, and click View Side by Side; turn on Synchronous Scrolling so both files move together. It's a manual visual scan with no marks, but for a small sheet it's often all you need.
To actually highlight the changed cells, use conditional formatting. There's one catch worth knowing up front: Excel won't let a conditional-formatting formula point at a different workbook, so both sheets have to live in the same file first. Right-click the second version's tab, choose Move or Copy, and copy it next to the original. Then:
=A2<>OtherSheet!A2 (point the second reference at the same cell on the other sheet).Every cell whose value differs from the other version is now colored. This is the answer to "compare two Excel files and highlight differences" for two sheets that line up row for row — and that condition is exactly where it gets fragile.
Conditional formatting compares by position: it checks row 5 against row 5, row 6 against row 6, and so on. That's correct only if nobody added, deleted, or sorted a row. The moment someone inserts a single row near the top of one version, every row beneath it shifts by one, and the position-based comparison reports a wall of differences that aren't real — the data matched, it just moved. On a version that a few people have edited, this happens whenever a row is inserted, deleted, or sorted.
What you actually want is a comparison keyed on an identifier — a SKU, an invoice number, an email, a customer ID — so each row is matched to its counterpart by what it is, not by where it sits. A keyed comparison answers the questions that matter: which keys exist in both versions and changed, which are new in the later file, and which disappeared from it. Excel's own robust route for this is Power Query. First make the key column the same data type in both tables. A Left Anti merge, run both ways, finds the rows added in the newer version and removed since the earlier one — but it only returns keys present on one side, so it can't reveal changed values for keys that exist in both. To catch those, merge on the key with a Full Outer join, expand both versions' columns, and compare the paired fields. It works and it refreshes, but it's several fiddly steps and it still leaves you to assemble the highlighted output by hand.
When the two files are real versions with rows that moved, and you need the answer as something you can send rather than a colored sheet you have to explain, the question stops being "which formula" and becomes "just tell me what changed, keyed by ID, and give me a highlighted workbook I can hand over." That is what Anomaly does in one request.
In Anomaly you import each version as a table — the earlier file as one upload, the newer file as a second — name the column that uniquely identifies each row as the key (a stable, nonblank key, or a composite key, with blank or duplicate keys checked first), and ask in plain language:
"These two tables are two versions of the same sheet, keyed by sku. Show every difference — for each changed row, which column changed and the old value vs the new value; the rows added in the newer version; and the rows removed since the earlier one. Give me a differences table I can download, and a highlighted Excel workbook with the changes color-coded."
It matches the two versions on the key with a full outer join, classifies every row as changed, added, removed, or unchanged, and builds a downloadable Excel workbook that highlights them — amber for a changed cell, a green row for an addition, a red row for a removal — alongside a plain differences table (one row per change, with the old and new value). Because it matched on the key rather than the row position, inserting or reordering rows does not create positional mismatches — provided the key is clean and uniquely identifies each row.
Try it on the two sample files
Download a3_inventory_v1.xlsx and a3_inventory_v2.xlsx — two versions of a four-row inventory sheet keyed by sku — upload both to Anomaly, and ask it to compare them. The figure below is a screenshot of the comparison workbook Anomaly produced from these exact files.
The highlighted comparison, keyed by SKU
sku key, not by row position.Two honest limits. The comparison is exact matching on a key you name (here sku) — it is not fuzzy or tolerance matching, and it is not a positional row-by-row diff, so tell it which column is the key, and make sure that key is stable, nonblank, and unique (or a composite key), since a non-unique key can multiply matches and blur the result. And the highlighting is delivered as color fills in the workbook you download, not painted onto your original file in place. Within those bounds it does the version-comparison job — keyed, highlighted, and shareable — without the Power Query assembly.
Comparing two CSV files is the same job with plainer inputs. Open both in Excel (or import them), and the same rules apply: if the rows still align, conditional formatting with =A2<>OtherSheet!A2 highlights the changed cells; if rows were added or removed, compare by a key instead. Because CSVs carry no cell formatting of their own, there's nothing to compare except the values — which makes them a clean input for a keyed comparison. Mind the output format, though: a CSV can hold a plain differences table, but it can't carry the color highlighting or the multi-sheet workbook, so export those as XLSX.
Two nearby jobs get tangled with this one, and they need different tools. Comparing two files for differences — what this page covers — is about what changed between two versions. Comparing two lists for duplicates usually means one of two other things: finding the values that appear in both lists (that's comparing two lists in Excel, a membership check), or removing repeated rows inside a single file (that's deduplicating one list with Remove Duplicates). If your real question is "which items are in both lists" or "how do I strip duplicate rows from one sheet," those are separate methods, not a version comparison. And combining or appending several files into one master sheet is a different job again — that is merging files, not comparing two versions of one.
Microsoft ships a dedicated comparison tool. Through the Inquire add-in, the Spreadsheet Compare command runs a full cell-by-cell comparison of two workbooks and lays the differences out in a two-pane grid, color-coded by the kind of change — entered values, calculated values, formulas, named ranges, cell formats, even line-by-line VBA code. For an audit of what changed between two versions, it's thorough and it's free if you already have it.
The catch is who has it. Spreadsheet Compare and the Inquire add-in ship only with Office Professional Plus and Microsoft 365 Apps for enterprise, on Windows — they aren't in the Home, Personal, or Business editions, and not on Mac. When you launch Compare Files from Excel's Inquire tab you need both workbooks open (the standalone Spreadsheet Compare app lets you browse to the two files instead), and like conditional formatting it aligns cells by position, so the same row-movement caveat applies. If you have the right edition, it's an excellent audit tool; if you don't, the keyed methods above are the portable answer.
What about Copilot? Copilot in Excel can import data from another workbook, which helps you pull both versions together — but importing is not comparing. Microsoft's documented workflow brings the data in; you still apply one of the methods above (conditional formatting when the rows align, a keyed comparison when they move) to get the before/after diff. Microsoft's documented import workflow does not itself produce the complete keyed, highlighted before/after diff shown here.
Which method fits the job
| What you need | Best method |
|---|---|
| A quick visual scan of two files | View Side by Side (View tab) |
| Highlight changed cells, rows still aligned | Conditional formatting, both sheets in one file |
| Compare when rows were added, removed, or reordered | A keyed comparison — Power Query, or Anomaly |
| A full cell-by-cell audit (formulas, formats, VBA) | Spreadsheet Compare (Windows, Professional Plus / Microsoft 365 Apps for enterprise) |
| Added / removed / changed rows as a downloadable, highlighted file | Anomaly |
For a quick look, open both files and use View → View Side by Side with Synchronous Scrolling. To highlight what changed, copy both versions into one workbook, select your data, and add a conditional-formatting rule with the formula =A2<>OtherSheet!A2 to color every changed cell. That works while the rows still line up. If rows were added, removed, or reordered, compare by a key column instead — with Power Query or Anomaly — because a position-based highlight will flag every row below a change as different. On Windows with Office Professional Plus or Microsoft 365 Apps for enterprise, the Spreadsheet Compare tool runs a full cell-by-cell report.
It depends on whether the rows still align. If nobody changed the row order, conditional formatting is a simple way to highlight the changed cells, and Excel's Spreadsheet Compare add-in (Windows, Professional Plus or Microsoft 365 Apps for enterprise) gives a thorough cell-by-cell audit. If rows were inserted, deleted, or sorted, a position-based comparison produces false differences, so match the two versions on a key column instead — in Power Query, a Left Anti merge both ways finds added and removed rows and a Full Outer merge with expanded fields catches changed values, or Anomaly returns a keyed, highlighted, downloadable comparison. Whichever you use, make the key columns the same data type and check for stray spaces and text-versus-number formatting first, since those cause false mismatches.
Yes. Spreadsheet Compare only ships with Office Professional Plus and Microsoft 365 Apps for enterprise on Windows, but you don't need it. Copy both versions into one workbook and use conditional formatting (=A2<>OtherSheet!A2) to highlight changed cells when the rows align, or use Power Query to compare the two tables by a key column when rows have moved. Anomaly can also compare the two files by key and return a highlighted, downloadable workbook without any add-in.
To compare two Excel files, first ask whether the rows can be trusted to line up. If they can, conditional formatting highlights the changed cells, and Spreadsheet Compare gives a full audit if your edition has it. If they can't — if rows were added, removed, or reordered — stop comparing by position and match the two versions on a key instead, so a moved row reads as moved rather than changed. That keyed comparison, returned as a highlighted workbook you can actually send, is the version-comparison job done properly.
Continue exploring AI data analysis with these related insights and guides.

The fast Excel way, and the harder one the button cannot do: dedupe by a key column, keep the most-complete row, and get an audited removed count.

A practical CSV upload recovery workflow for file size, encoding, delimiters, headers, malformed rows, validation, and safe re-upload.

A precise guide to the five advanced Excel workflows where Anomaly AI is faster than pivot tables, and where Excel still wins.