Compare Two Excel Sheets: Methods and Formulas
In this article
To compare two Excel sheets, first make sure the records are aligned by a unique ID, then use a formula such as =IF(Sheet1!B2=Sheet2!B2,"Match","Different") to compare corresponding cells. If rows may be in a different order, look up each ID on the other sheet and compare the associated values instead; for visual checks, Conditional Formatting can highlight differences.
Choose the right comparison method
The best method depends on what “compare” means for your workbook. You may want to find changed values in records that appear on both sheets, identify rows present on only one sheet, or scan two similarly arranged tables for any unequal cells. Before comparing, check that both sheets use the same column headings, data types, and definition of a record.
- Same row order and layout: compare matching cells with a direct formula or Conditional Formatting.
- Different row order, shared ID: find records by their ID, then compare the related fields.
- Missing or added records: check whether each ID exists on the other sheet.
- Large or recurring comparisons: consider Power Query, which can merge tables using a key and show unmatched records.
Do not assume that row 20 on one sheet represents the same record as row 20 on another. Sorting, inserted rows, or filtered data can break that assumption without making the sheets look obviously different.
Compare matching cells when rows line up
Suppose both sheets contain the same records in the same order, with product IDs in column A and prices in column B. On a third sheet, enter a comparison formula in C2. With the price values in Sheet1!B2 and Sheet2!B2, this formula returns “Match” when they are equal and “Different” otherwise:
=IF(Sheet1!B2=Sheet2!B2,"Match","Different")
Copy it down to compare further rows. In Excel, sheet names without spaces can be referenced directly. If a sheet name contains spaces, enclose it in single quotes, as in ='January Sales'!B2. A practical approach is to add a result column for each field that matters, or compare a whole row using an AND test. With values in B2:D2 on both sheets, this returns “Match” only if all three corresponding cells match:
=IF(AND(Sheet1!B2=Sheet2!B2,Sheet1!C2=Sheet2!C2,Sheet1!D2=Sheet2!D2),"Match","Different")
These are exact comparisons: a changed digit or extra space counts as different. Excel generally compares text without distinguishing uppercase from lowercase in ordinary equality tests, so “North” and “NORTH” may be treated as equal. If capitalization matters, use the EXACT function; with the two text values in Sheet1!B2 and Sheet2!B2, =EXACT(Sheet1!B2,Sheet2!B2) returns TRUE only when their text and capitalization match.
Match records when row order differs
When rows are not aligned, use a stable unique key, such as an employee number or invoice ID. Avoid using a name alone if names can repeat. For example, if Sheet1 has IDs in A and amounts in B, and Sheet2 has IDs in A and amounts in B, look up Sheet1’s ID on Sheet2 and compare the amount. With the ID in Sheet1!A2, put this formula in Sheet1!C2:
=IFERROR(IF(B2=XLOOKUP(A2,Sheet2!A:A,Sheet2!B:B),"Match","Different"),"Not found")
XLOOKUP is available in Microsoft 365 and Excel 2021 or later. The formula returns “Not found” if the ID does not appear on Sheet2; otherwise, it compares the amount and reports whether it matches. Copy it down for the remaining records. If a key occurs more than once, XLOOKUP returns one matching result, so duplicates should be investigated or combined into a genuinely unique key before relying on the comparison.
To find IDs on Sheet1 that do not appear on Sheet2, use a membership check. With the ID in Sheet1!A2 and the comparison list in Sheet2!A2:A1000, =IF(COUNTIF(Sheet2!$A$2:$A$1000,A2)=0,"Missing from Sheet2","Found") marks missing IDs. Repeat in the opposite direction to identify records found only on Sheet2. Adjust the range to cover the actual list.
Highlight differences without adding result columns
Conditional Formatting can color cells that differ while leaving the source tables intact. For aligned data, select the range to evaluate, such as B2:D100 on Sheet1, then choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter =B2<>Sheet2!B2, choose a format, and confirm. The formula compares each selected cell with the corresponding cell on Sheet2 as Excel applies the rule across the range.
For a large or important comparison, a separate results column is usually easier to audit than color alone: colors can be missed, and they do not explain why a value differs. Conditional Formatting is most useful as a quick visual scan. In Excel for Mac, the same Conditional Formatting feature is available from the Home tab, though dialog layouts can vary by release. Excel for the web also supports Conditional Formatting, with some differences in rule creation compared with desktop Excel.
Use Power Query for repeatable comparisons
Power Query is useful when tables are large, regularly refreshed, or need a full list of matches and unmatched records. Format each data range as a table, then use Data > Get Data to load the tables into Power Query. In the Power Query Editor, use Home > Merge Queries, select the key column in each table, and choose the appropriate join type. An inner join returns matching keys; a left anti join returns rows from the first table that have no match in the second. Expand the merged columns to inspect values side by side.
Menu wording and available connectors can differ by Excel edition and platform. Power Query is included in Microsoft 365 Excel for Windows; Mac availability and capabilities depend on the Excel release. Refreshing the query updates the comparison from the source tables, but it does not automatically resolve conflicting values. Review the output and preserve an unchanged copy of source data before making corrections.
Common causes of misleading results
- Extra spaces: “Item A” and “Item A ” may look alike but differ. TRIM can remove ordinary leading and trailing spaces from text; inspect unusual nonbreaking spaces separately.
- Numbers stored as text: a value like 100 may be stored as text in one sheet and as a number in the other. Normalize the data type before comparing.
- Dates and displayed values: cells can show the same date while containing different underlying times. Compare the underlying values or deliberately compare date-only values if time is irrelevant.
- Rounding: displayed currency may show two decimals while stored values differ beyond those decimals. Decide whether to compare exact values or rounded values.
- Blank cells and formulas: a formula returning an empty string is not necessarily the same as a truly empty cell. Check whether you need to compare displayed results or underlying formulas.
- Duplicate keys: duplicates can make a lookup appear valid while comparing the wrong occurrence. Check uniqueness before matching records.
Also check whether filters hide rows and whether either sheet has been sorted independently. A useful safeguard is to compare record counts and check for missing IDs in both directions before interpreting the field-by-field results.
Frequently Asked Questions
Can Excel compare two sheets automatically?
Excel can compare sheets with formulas, Conditional Formatting, or Power Query, but it does not infer which columns define a record. You must choose the key and decide which differences matter.
How do I compare two sheets and highlight differences?
When rows and columns align, select the cells and create a Conditional Formatting rule using a formula such as =B2<>Sheet2!B2. For records in a different order, match by a unique ID first.
Can I compare sheets if their rows are in a different order?
Yes. Use a unique ID to find each record on the other sheet, then compare its fields with XLOOKUP or Power Query. A direct cell-by-cell comparison is unreliable when row order differs.
How do I find rows that are missing from one sheet?
Use COUNTIF to test each ID against the other sheet’s ID range, or use a left anti join in Power Query. Run the check in both directions to find rows unique to either sheet.
Why does Excel say values are different when they look the same?
Possible causes include extra spaces, text-versus-number formatting, hidden time values in dates, small decimal differences, or formulas that display blank text. Inspect the underlying values and normalize the data before comparing.