How to Run a Diff in Excel: Compare Two Sheets
In this article
Excel has no single "diff" button, but you can compare two versions of a spreadsheet in a few minutes using a helper formula that flags changed cells. The simplest approach is to put both versions side by side (or in one workbook on two sheets), then use a formula like =A2=Sheet2!A2 in a third area to mark every cell that differs, and filter or highlight the results. If you have a Microsoft 365 subscription, Microsoft's own Spreadsheet Compare tool does a deeper job, including formulas and formatting.
What You'll Need
- Both versions of the workbook (the "old" file and the "new" file), ideally with the same sheet layout.
- Excel on desktop (Windows or Mac) for the formula method. The built-in compare tool is a Windows add-in, so Mac users should stick to formulas or a third-party tool.
- Headers in row 1 and data starting in row 2 on each sheet, so formulas line up cleanly.
- Roughly five minutes and a spare empty column or worksheet to hold the comparison results.
Step-by-Step
- Back up both files first. Save a copy of each workbook under a new name (for example Budget_old.xlsx and Budget_new.xlsx). Comparing is read-only, but you will be adding helper columns, and it is easy to overwrite the wrong sheet.
- Bring both versions into one workbook. The easiest layout is two sheets in a single file. In the new workbook, right-click a sheet tab and choose Move or Copy, tick Create a copy, and repeat so both versions sit side by side. Rename the tabs clearly, such as Old and New. Confirm that rows and columns refer to the same records in both sheets; if one version has an inserted row, every comparison below it will be off by one.
- Pick a comparison column. In a third sheet (call it Diff), copy the identifiers from the first sheet, for example the order numbers or names in column A, so you have something to match rows on. Without a stable key, a diff only tells you that something moved.
- Write the comparison formula. In cell B2 of the Diff sheet, enter a formula such as
=Old!B2=New!B2. This returns TRUE when the two cells match and FALSE when they differ. Copy it across the columns you care about and down to the last row. - Make the result readable. Wrap the formula so it says what you mean:
=IF(Old!B2=New!B2,"","CHANGED"). Instead of a wall of FALSE values, you now get a blank cell for matches and the word CHANGED where something moved. For a single-cell verdict on the whole row, use=IF(COUNTIF(Old!2:2,New!2:2)=COLUMNS(Old!2:2),"SAME","DIFF")or simply count the CHANGED labels. - Handle blanks and text carefully. A formula comparing a number to text, or a blank cell to a zero, will report a difference that is not meaningful. If blanks are possible, use
=IF(TRIM(Old!B2&"")=TRIM(New!B2&""),"","CHANGED")to normalise them. Note that this still treats a number stored as text as different from a true number. - Filter or highlight the differences. Select the helper row containing the labels, turn on Data > Filter, and filter out blanks so only the changed columns remain. Alternatively, select your comparison range and use Home > Conditional Formatting > Highlight Cells Rules > Equal To, then type CHANGED. Labels can differ slightly by Excel version, device and region, so look for the equivalent command if yours reads differently.
- Check the totals as a sanity test. Put
=SUM(Old!C:C)and=SUM(New!C:C)next to each other. If both columns match cell by cell but the totals differ, you probably have a value that moved rather than changed, or a row that was added at the bottom of one sheet only. - Log what you find. Add a notes column beside the CHANGED flags and write what happened to each row (price updated, quantity corrected, row deleted). This turns the diff into an audit trail you can share or file.
- Try the built-in tool if you have Microsoft 365 on Windows. The Spreadsheet Compare add-in (part of the Office installation on many business plans) opens two workbooks and produces a report showing changed values, entered and deleted rows, formulas and formatting. Open it from the Start menu or the Office tools folder, pick the two files, and click Compare. It is Windows-only, so do not expect to find it on Mac, iPad or Excel for the web.
Common Mistakes
- Comparing sheets with different row orders. A row-by-row formula assumes record 5 on one sheet is the same record as row 5 on the other. Sort both by a unique key first, or use
VLOOKUPorXLOOKUPto pull matching values before comparing. - Forgetting hidden characters. Trailing spaces, non-breaking spaces pasted from a web page, and inconsistent capitalisation all register as differences. Wrap comparisons in
TRIMandUPPERif the source data is messy. - Comparing formatting with a value formula. Cell formulas only see contents. Bold text, fills and number formats need the built-in compare tool or manual checking.
- Comparing formulas instead of results. If one sheet links to another workbook and shows an error, the comparison reports a difference even though the underlying numbers agree.
- Editing the original files. Always work on copies so you can re-run the comparison if you get confused.
Tips
- Name your sheets short and distinct (Old, New) to keep formulas readable.
- Freeze the top row while you scan results, so headers stay visible.
- Use View > New Window to open the same workbook twice and arrange the windows side by side for visual spot-checking.
- For large files, compare a hash or a count first: if the total number of rows and the sum of a key column both match, you may not need a full cell-by-cell diff.
- If you diff regularly, save the helper sheet as a template so the formulas are already in place next time.
Troubleshooting
- Every cell reads CHANGED. Check for trailing spaces or text-versus-number mismatches. Select a suspect cell on each sheet and look at the alignment: text defaults to left, numbers to right. Data > Text to Columns can convert text-formatted numbers.
- Nothing reads CHANGED but the files look different. You may be comparing the wrong range or sheet references. Confirm the sheet names in the formula match the actual tab names; Excel updates references automatically when tabs are renamed, but copied formulas can point at the old ones.
- Formulas return #REF! errors. A referenced sheet or column was deleted. Retype the reference rather than editing it, and check the spelling of the sheet name.
- Results stop partway down. The formulas were dragged only over part of the range. Copy the bottom row and paste it into the remaining rows, or double-click the fill handle.
- The compare tool is missing. It ships with some Microsoft 365 and Office installations, not all, and it is not available on Mac or the web app. Use the formula method instead.
Frequently Asked Questions
Does Excel have a built-in compare feature?
Only on Windows in certain Microsoft 365 and Office installations, through the Spreadsheet Compare tool. Excel for Mac, Excel for the web and the mobile apps have no built-in diff, so use the formula method described above.
Can I compare two separate workbooks without combining them?
Yes. Open both files and reference the other workbook in your formula, for example =[Book1.xlsx]Sheet1!A1=[Book2.xlsx]Sheet1!A1. Both files must stay open while Excel recalculates, and the reference breaks if a file is moved or renamed.
How do I find rows that exist in one sheet but not the other?
Use =IF(COUNTIF(New!A:A,Old!A2)=0,"MISSING","") to flag identifiers present in the old sheet but absent from the new one, and the reverse formula for the other direction.
Will a diff show formatting changes?
Not with formulas. Only the Spreadsheet Compare tool reports formatting, and even then only some kinds. For anything visual, place the sheets side by side and compare manually.
Can I diff files on a phone?
The Excel mobile apps can display two workbooks but have no comparison feature, and formulas referencing another open workbook do not recalculate reliably there. Do the comparison on a desktop.