How to Check if Two Columns Match in Excel
In this article
Use a formula in a third column: =A2=B2 returns TRUE when the two cells match and FALSE when they do not. Drag it down the column to compare every row, then filter or sort by TRUE/FALSE to see all mismatches at once.
Time 5 min · Steps 7 · Level Easy
The most common way this goes wrong is comparing cells that look identical but differ by a stray space, a different number format, or text that only looks like a number. The fix is to build the comparison in a helper column first, then clean up the mismatches it finds. A direct formula also beats eyeballing two long columns side by side, which misses differences easily once you pass a few dozen rows.
Set Up Your Sheet Before You Compare
Before typing any formula, get the layout right so the comparison works on the first try. Excel needs the two columns to be the same length and in the same worksheet, or at least in workbooks you can reference.
- Put the two columns side by side if you can (for example column A and column B) so formulas are short and easy to read.
- Check that both columns start on the same row, typically row 2 if row 1 holds headers.
- Count the rows in each column. If one is longer, the extra rows have nothing to compare against and will show as mismatches.
- Make sure both columns hold the same type of data. A cell containing the text "123" and a cell containing the number 123 will not always compare the way you expect.
- Save a copy of the file first if you plan to delete or move rows based on the results.
Compare Two Columns Row by Row
The basic comparison is one formula per row, filled down. This is the method to reach for when both columns are in the same order and you want to know which rows agree.
- Click the first empty cell next to your data, for example C2 if your data starts in A2 and B2.
- Type the formula =A2=B2 and press Enter. The cell shows TRUE if the two cells match and FALSE if they differ.
- Fill the formula down by selecting C2, then double-click the small square at the bottom-right corner of the cell, or drag it down to the last row of your data.
- Read the results: every row showing TRUE matches, every row showing FALSE does not. A quick count of mismatches appears in the status bar if you select the column.
- Turn TRUE/FALSE into words with =IF(A2=B2,"Match","Different") if you plan to show the sheet to someone else.
- Ignore capitalisation and extra spaces by using =EXACT(TRIM(A2),TRIM(B2)) only when you want case to matter, or =TRIM(A2)=TRIM(B2) when you do not. TRIM removes leading and trailing spaces, the most common cause of false mismatches.
- Highlight mismatches without a formula by selecting both columns, then using Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values (menu names can differ slightly by version). Duplicates highlight the matches, leaving the unmatched cells unhighlighted.
Compare Columns in Different Orders
When the two columns are not sorted the same way, a row-by-row comparison is the wrong tool. You need to ask whether each value in one column exists anywhere in the other column.
Use =COUNTIF(B:B,A2) in C2 and fill down. A result of 0 means the value in A2 appears nowhere in column B; a result of 1 or more means it appears at least once. If you only expect each value once, =IF(COUNTIF(B:B,A2)=0,"Missing","Found") gives you plain words.
For a two-way check, put =COUNTIF(A:A,B2) in D2 as well. Column C then tells you which column A values are missing from column B, and column D tells you which column B values are missing from column A. This is the standard way to reconcile two lists, such as two sets of invoice numbers or employee names.
For large sheets, referencing the whole column (B:B) is slower than a fixed range like $B$2:$B$5000. On a list of a few thousand rows either works fine; on tens of thousands, use the fixed range.
Spot the Mismatches and Clean Them Up
Once the formulas are in, the job is to see the problem rows quickly and fix the data, not the formula. Filter the helper column to FALSE or "Different", and only the mismatched rows remain visible.
To filter: select your header row, then Data > Filter, click the arrow on the helper column header, and untick TRUE (or "Match"). Fix or delete the visible rows, then clear the filter when done.
Symptom, cause and fix
| Symptom | Likely cause | Fix |
|---|---|---|
| Everything shows FALSE | One column is text, the other is numbers, or both columns are offset by one row | Check that row 2 in both columns holds the same record; convert text numbers with the error-checking option or VALUE |
| Cells that look equal show FALSE | Extra spaces, or a number formatted differently (12 vs 12.00) | Wrap both sides in TRIM, or round numbers with ROUND |
| Formula shows instead of TRUE/FALSE | The cell is formatted as text | Change the cell format to General, then re-enter the formula |
| Some rows show no result | The columns are different lengths | Extend the formula only to the last row of the shorter column and investigate the extra rows separately |
| COUNTIF misses a value you can see | Wildcards: the value contains * or ? which COUNTIF treats as wildcards | Use =COUNTIF(B:B,SUBSTITUTE(A2,"*","~*")) or compare with a different method |
How to tell it worked
Spot-check three rows by hand: one TRUE, one FALSE, and one near the bottom of your data. If the formula agrees with your eyes on those three, the fill-down worked and no rows were skipped. Then select the helper column and check the count of TRUE and FALSE in the status bar; the two counts should add up to your total number of data rows.
Finishing up
When you are done, decide what to do with the helper column. Keep it if the sheet will be updated and you want the comparison to refresh automatically, since the formulas recalculate on their own. Delete it if the comparison was a one-off: select the column, right-click, and choose Delete. If you copied formula results into another sheet, use Paste Special > Values first, otherwise you will paste broken references. If you used Conditional Formatting instead, clear it with Home > Conditional Formatting > Clear Rules.
Official source: Microsoft Support