How to Compare Two Excel Sheets: Same Workbook, Three-Sheet Method
Two sheets in one workbook is the easier case — conditional formatting works, references are direct, and nothing needs copying. The three-sheet pattern below is the one worth reusing.
Short answer
Why sheets are easier than files
| Two sheets, one file | Two separate files | |
|---|---|---|
| Cross-references | Direct sheet references in a formula | External links that break when the file moves |
| Conditional formatting | Works — a rule can reference another sheet in the same workbook | Does not work — a formatting rule cannot reference another workbook |
| Formulas referencing the other sheet | =Sheet2!A1 | ='[File.xlsx]Sheet2'!A1 |
| Copying data | Not required | Required, and it is where transcription errors enter |
| Sharing | One person edits at a time | Two people can work separately |
The practical consequence: if your two sets of data are in separate files and you are doing anything more than a one-off visual check, copy them into one workbook first. You lose nothing and you gain the ability to use formatting and simple references.
Option 1: view them side by side
For a quick visual check on a small amount of data, Excel can show the same workbook in two windows with a different sheet in each.
- 1Go to View → New Window. This opens a second window onto the same workbook.
- 2Use View → Arrange All → Vertical to place the two windows side by side.
- 3In each window, select the sheet you want to look at.
- 4Turn on View → Side by Side → Synchronous Scrolling if you want both to scroll together.
This is viewing, not comparing
Option 2: the three-sheet comparison — the method worth reusing
Leave your two source sheets untouched and build the comparison in a third sheet. Never compare the two source sheets directly to each other with ad-hoc formulas scattered across both — the logic disappears the moment you close the file.
| Sheet | Contains | Rule |
|---|---|---|
| Sheet1 — say, the register | Your first data set | Do not edit. This is the source of truth for one side |
| Sheet2 — say, the export | Your second data set | Do not edit. This is the source of truth for the other side |
| Compare | The key list and the match columns | The only sheet with formulas |
Step 1: build the key list on the Compare sheet
The Compare sheet needs one row per key. Copy the key column from Sheet1, then add any keys that are on Sheet2 but not Sheet1. The simplest way is to copy both key columns into a single column, one below the other, and use Data → Remove Duplicates.
Before you do, normalise the key using the same formula on both source sheets — strip spaces, force upper case, remove separators:
=UPPER(TRIM(SUBSTITUTE(A2,"/","")))
This is the step people skip, and it is the reason most comparisons report a long list of false differences.
Step 2: test each key on both sides
| Column | Formula | What it tells you |
|---|---|---|
| In Sheet1? | =COUNTIF(Sheet1!$A:$A, $A2)>0 | TRUE if this key exists in the register |
| In Sheet2? | =COUNTIF(Sheet2!$A:$A, $A2)>0 | TRUE if this key exists in the export |
| Status | =IF(AND(B2,C2),"In both",IF(B2,"Only in register","Only in export")) | The finding, in words |
That status column is the whole comparison, reduced to one phrase per row. Filter it and you have your three lists: records in both, records only in the register, records only in the export.
Step 3: compare the values where the key is present on both sides
| Column | Formula | What it tells you |
|---|---|---|
| Value in Sheet1 | =IFERROR(XLOOKUP($A2, Sheet1!$A:$A, Sheet1!$D:$D), "") | The amount from the register |
| Value in Sheet2 | =IFERROR(XLOOKUP($A2, Sheet2!$A:$A, Sheet2!$D:$D), "") | The amount from the export |
| Difference | =IF(OR(F2="",G2=""), "", F2-G2) | Blank when one side is missing — not a misleading zero |
| Result | =IF(AND(B2,C2), IF(ABS(H2)<=1, "Matched", "Amount difference"), "Missing") | Matched, different, or missing |
Never let a missing record look like a zero difference
Step 4: total both sides
At the bottom of the Compare sheet, total the value columns from each side and the difference column. The total of the difference column must equal the gap between the two source totals. If it does not, some row is not being captured by your key list — usually a key that exists on one side but was never copied in.
Option 3: conditional formatting for the visual pass
Once both sheets are in one workbook, formatting becomes available. Two rules do most of the work.
| Rule | Applies to | Formula |
|---|---|---|
| Highlight keys on Sheet1 that are absent from Sheet2 | Sheet1 key range | =COUNTIF(Sheet2!$A:$A, $A1)=0 |
| Highlight keys on Sheet2 that are absent from Sheet1 | Sheet2 key range | =COUNTIF(Sheet1!$A:$A, $A1)=0 |
| Highlight a value that differs from the other sheet | Sheet1 value range | =AND($A1<>"", ABS($D1-IFERROR(XLOOKUP($A1,Sheet2!$A:$A,Sheet2!$D:$D), $D1))>1) |
Use two clearly different fill colours — one for missing, one for different. A single colour for both conditions forces you to read every highlighted cell to know which problem you have.
Comparing more than two sheets
Comparing each pair of sheets in turn does not scale. Designate one sheet as the master key list and add a column group per source sheet.
| Key | In Register? | In Export? | In Vendor file? | Register value (₹) | Export value (₹) | Vendor value (₹) | Status |
|---|---|---|---|---|---|---|---|
| KP/2025/1874 | Yes | Yes | Yes | 1,18,000 | 1,18,000 | 1,18,000 | All matched |
| KP/2025/1902 | Yes | Yes | No | 82,050 | 82,050 | — | Missing in vendor file |
| KP/2025/1955 | Yes | No | Yes | 1,45,000 | — | 1,45,000 | Missing in export |
| KP/2025/1988 | Yes | Yes | Yes | 76,850 | 76,850 | 80,000 | Vendor file differs by 3,150 |
One row per key, one column group per source. Adding a fourth file means adding a column pair, and the status column can be written once as a nested IF or a SWITCH.
The traps specific to sheet comparisons
- Hidden or filtered rows. A filtered sheet shows fewer rows than it contains, and a copy-paste of a filtered range copies only the visible rows. If you built the key list from a filtered view, your comparison is missing records and nothing warns you.
- Numbers stored as text. Common after a paste from a PDF, a web page or a bank export. Both key columns must be the same type — the quickest test is to check whether the values sit right-aligned (numbers) or left-aligned (text) in their cells.
- Non-breaking spaces. A copied value can carry a character that
TRIMdoes not remove. If two values look identical and will not match, wrap the key inCLEAN()as well. - Leading zeros lost. An employee code of 00417 becomes 417 when a sheet is formatted as a number or exported to CSV. The two sides then never match. Format both key columns as text before importing.
- Merged cells. A merged cell holds its value in the top-left cell only, so a formula reading the merged range sees blanks in every other row. Unmerge before comparing.
- Sheet names with spaces. Any reference to a sheet whose name contains a space needs single quotes —
'Sheet 1'!A1. Without them the formula errors, and people often “fix” it by retyping the reference and changing the meaning. - 3-D references. A reference such as
Sheet1:Sheet3!D10reads through every sheet between the two named ones in tab order. It is a neat trick for totalling identical sheets and a serious hazard in a comparison, because dragging a sheet tab changes what the formula reads.
When the sheet comparison outgrows the sheet
The three-sheet pattern above is the right answer for most work, and it is entirely within reach of anyone comfortable with COUNTIF and XLOOKUP. Two things push people past it: volume, where formulas repeated down fifty thousand rows make the file slow to open and slow to recalculate, and repetition, where the same comparison has to be rebuilt every month because the sheet names or the column positions changed.
Power Query handles the repetition well if you are comfortable with it. If you would rather the comparison simply be a saved set of rules — this key column, this tolerance, this is what counts as a difference — then it belongs in a tool rather than a worksheet. The Piloteq Automate comparison page shows what that returns. If you are comparing two separate files rather than two sheets, start with compare two Excel files.
If you would rather not build this by hand
Compare the two sheets and get the difference list
Piloteq Automate matches the key columns you choose and returns the records missing from each sheet, plus the records present in both with different values — with the reason written next to every result.
- ✓Missing records reported separately for each side
- ✓Value comparison with a tolerance you set
- ✓Duplicate detection before the comparison runs
- ✓A difference list you can export and filter
Frequently asked questions
How do I compare two sheets in the same Excel workbook?+
Add a third sheet and build the comparison there. On that sheet, list the key from one of the two sheets, then use COUNTIF to test whether each key exists on the other sheet and XLOOKUP to pull the value across, with an IF to flag rows where the values differ. Because all three sheets are in one workbook, you can also apply conditional formatting, which is not possible when the data is in two separate files.
Can I view two sheets side by side?+
Yes. Open a second window for the same workbook through View, then New Window, use Arrange All to place the two windows side by side, and use View Side by Side with Synchronous Scrolling. Both windows show the same workbook, so you can put a different sheet in each. This is useful for a visual check on a small amount of data, but it is not a comparison — it does not tell you which rows are missing.
Does Excel have a built-in compare sheets feature?+
Not in the current versions. Older versions of Excel offered Compare and Merge Workbooks as part of shared workbooks, but that feature is no longer present in modern Excel. What remains is the manual method — formulas on a comparison sheet — plus the separate Spreadsheet Compare program that ships with certain Office editions.
Why does my sheet comparison show differences that are not real?+
Almost always because of the data types. A number stored as text does not equal the same number stored as a number, and a date typed as text does not equal a real date. Trailing spaces, non-breaking spaces from a copied web page, and invoice numbers that lost a leading zero are the other frequent causes. Converting both key columns to the same type before comparing removes nearly all of these.
How do I compare sheets when the columns are in a different order?+
Map the columns by name rather than comparing by position. Build a small mapping row that records which column on Sheet 1 corresponds to which column on Sheet 2, and reference the mapped names in your formulas. If you compare positionally, a sheet where the amount column has moved will report every single row as different.
How do I compare more than two sheets?+
Designate one sheet as the master list of keys, then add a pair of columns for each sheet being compared — one testing whether the key exists, one for the value. That produces a matrix with a row per key and a column group per source, which is far easier to read than comparing each pair of sheets in turn. It also scales: adding a fourth sheet means adding two columns, not building a fourth comparison.