How to Compare Two Excel Sheets and Find Differences
In this article
To compare two Excel sheets, use a formula when the cells occupy matching positions, or use conditional formatting to highlight differences visually. For a quick cell-by-cell check, if the values to compare are in Sheet1 and Sheet2 in the same workbook, enter =IF(Sheet1!A1=Sheet2!A1,"Match","Different") in a third sheet and fill it across and down; it reports whether the two corresponding cells are equal.
Choose a comparison method
The right method depends on what “compare” means in your workbook. A positional comparison checks the same address on each sheet—for example, Sheet1!A2 against Sheet2!A2. A record comparison matches rows by an identifying value, such as an employee ID, because the rows may be sorted differently. A visual comparison is useful when you want to inspect changes in place, while a summary formula or Power Query comparison is better for larger or recurring tasks.
- Same layout and order: Use a formula or conditional formatting to compare corresponding cells.
- Same records, different order: Look up a unique key on the other sheet, then compare the related fields.
- Large or repeated comparisons: Consider Spreadsheet Compare, if available in your Office edition, or Power Query.
- Different workbooks: Open both files and use formulas with external references, or bring the data into one workbook before comparing.
Before comparing, check that both sheets use the same headers, data types, and conventions. A date stored as text, a number with hidden decimal places, or a stray space can make apparently similar entries compare differently.
Compare matching cells with a formula
For a direct comparison, create a blank worksheet such as “Check.” Put this formula in Check!A1, assuming Sheet1!A1 and Sheet2!A1 are the first cells you want to compare:
=IF(Sheet1!A1=Sheet2!A1,"Match","Different")
In Excel, sheet names without spaces can be referenced directly. If a sheet name contains spaces or certain punctuation, enclose it in single quotation marks, as in =IF('January Data'!A1='February Data'!A1,"Match","Different"). Select the formula cell and use the fill handle—the small square at the lower-right corner—to copy it through the comparison range. Excel adjusts relative references as the formula fills.
For example, if both sheets contain product names in column A and quantities in column B, put the formula in the corresponding position on the Check sheet and fill it through the rows and columns being checked. “Match” means the values compare equal; “Different” flags a discrepancy. You can filter the Check sheet for “Different” if you want to focus on exceptions.
To return the first sheet’s value when the cells match and show the second sheet’s value when they do not, use =IF(Sheet1!A1=Sheet2!A1,Sheet1!A1,"Sheet2: "&Sheet2!A1). If you need to show both values, a formula can concatenate them, but format dates and numbers deliberately: concatenation may display a date as its underlying serial number or omit the number format you expect.
Highlight differences with conditional formatting
Conditional formatting colors mismatches directly on a worksheet, which can be easier to review than a separate grid of results. To highlight cells on Sheet1 that differ from the same positions on Sheet2, select the relevant range on Sheet1—for example, A1:D100—and choose Home > Conditional Formatting > New Rule. Select Use a formula to determine which cells to format, enter =A1<>Sheet2!A1, choose a format, and select OK.
The formula’s A1 reference should match the top-left cell of the selected range. Excel adjusts it for the other cells. If Sheet2’s name has spaces, use a quoted reference, such as =A1<>'February Data'!A1. This rule highlights differences in the selected range, but it does not by itself identify missing rows or records that have moved to another position.
For a visible match check rather than a highlight, use the formula method. Conditional formatting rules can also become confusing when applied to ranges with merged cells, existing rules, or formulas that return empty text, so inspect the rule’s “Applies to” range if the results look incomplete.
Compare records when rows are rearranged
A cell-by-cell comparison is not suitable when rows can move. If each record has a unique ID, use that ID to find the corresponding record on the other sheet, then compare fields. In Microsoft 365 or Excel 2021 and later, XLOOKUP is one option. Suppose Sheet1 has IDs in A2:A100 and names in B2:B100, while Sheet2 has IDs in A2:A100 and names in B2:B100. Put this formula in Sheet1!C2 to find the name for its ID in Sheet2:
=XLOOKUP(A2,Sheet2!$A$2:$A$100,Sheet2!$B$2:$B$100,"Not found")
Copy it down. It returns the matching name from Sheet2, or “Not found” if the ID is absent. To compare that returned name with the name in Sheet1!B2, use this in D2:
=IF(C2="Not found","Missing from Sheet2",IF(B2=C2,"Match","Different"))
This example assumes IDs are unique. Duplicate IDs can cause an ambiguous match; clean or investigate duplicates before relying on the result. XLOOKUP is available in Microsoft 365 and Excel 2021 or later, but not in older perpetual versions such as Excel 2019. For older versions, INDEX and MATCH can perform a similar lookup, though the formula is less direct.
Compare separate workbooks and larger files
If the sheets are in separate workbooks, open both files and create a formula that references the other workbook. Excel will generally build the external reference when you type an equals sign, switch to the other workbook, select a cell, and press Enter. External references can include the workbook name and file path. Keep in mind that moving or renaming the source file may break the link, and recipients may see prompts to update links.
For a repeatable comparison of sizable tables, Power Query can import each table, clean or standardize the data, and merge the queries using a key column. In Microsoft 365 for Windows, start from Data > Get Data or use Data > From Table/Range for data already in the workbook. A merge can reveal records present in one table but not the other, as well as matched records whose fields differ. The exact commands available can vary by Excel edition and data source; refresh the query after the source data changes.
Some Microsoft Office editions include Spreadsheet Compare, a separate Windows desktop tool that reports workbook differences, including changes to formulas and formatting. Availability depends on the Office edition and installation, so check whether “Spreadsheet Compare” appears in the Windows Start menu. It is not the same as a normal worksheet formula and is not included in every Microsoft 365 plan.
Common causes of false differences
- Extra spaces: “North” and “North ” are not equal. TRIM can remove ordinary leading and trailing spaces, although it does not remove every kind of nonbreaking space.
- Numbers stored as text: The text value “0012” and the number 12 may not compare as intended, especially if leading zeros are meaningful identifiers. Standardize the data type without discarding meaningful zeros.
- Rounding: Values that display as 2.5 can differ underneath because of decimal precision. Decide whether exact values or rounded values matter before comparing.
- Formulas versus results: A normal equality formula compares calculated cell values, not whether the underlying formulas are identical. To inspect formula differences, use Excel’s formula display or an appropriate workbook comparison tool.
- Blanks and formulas returning empty text: A truly empty cell and a formula that returns an empty string can behave differently in some tests. Check the underlying cells if a result is surprising.
Also make sure the comparison range includes all relevant rows and columns. A formula filled only to row 100 cannot detect a difference in row 101. Save a copy before applying broad edits or cleanup operations, particularly when standardizing data for comparison.
Frequently Asked Questions
Can Excel compare two sheets automatically?
Excel can compare them with formulas, conditional formatting, Power Query, or Spreadsheet Compare where available. A formula does not automatically know which rows represent the same record; use a stable key when row order differs.
How do I find rows that are missing from one sheet?
Match records using a unique ID and look up that ID on the other sheet. A result such as “Not found” identifies an ID absent from the lookup range. Check for duplicate IDs and confirm that the lookup range includes the full dataset.
Does the IF formula compare formatting?
No. =IF(Sheet1!A1=Sheet2!A1,"Match","Different") compares cell values, not font, fill color, borders, or other formatting. Use Spreadsheet Compare if available, or inspect formatting with a separate method.
Can I compare sheets in Excel for Mac or Excel for the web?
Basic worksheet formulas and conditional formatting are available in current Excel for Mac and Excel for the web, though ribbon labels and some features may differ. Spreadsheet Compare is a Windows desktop tool and is not available as the same built-in comparison application on Mac or the web.
Why does Excel say two cells are different when they look the same?
Common causes include hidden spaces, text-versus-number differences, unrounded decimal values, and dates stored as text. Inspect the formula bar and cell formats, then standardize the values according to what the data represents.