Compare two columns in Excel for matches and differences
Updated · Checked on a live sheet · Excel and Google Sheets
The formula
To compare two columns in Excel for matches when the values can be in different rows, count each value in the other column: =IF(COUNTIF($G$2:$G$8, B2)>0, "Yes", "No") shows Yes for a match and No for a difference. When the two columns line up row by row, compare each pair directly: =IF(C2=D2, "Match", "Differs"). Filter the result column for No (or Differs) to see only the differences.
In general: =IF(COUNTIF(other_list, value)>0, "Yes", "No")
Try it on a live sheet
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Order | SKU | Qty | In price list? | SKU | Product | Price | Stock | ||
| 2 | 2001 | PL-104 | 2 | Yes | PL-101 | Fern | $9.50 | 40 | ||
| 3 | 2002 | PT-210 | 1 | Yes | PL-104 | Monstera | $34.00 | 12 | ||
| 4 | 2003 | TL-301 | 3 | Yes | PL-107 | Snake plant | $22.00 | 25 | ||
| 5 | 2004 | PL-101 | 1 | Yes | PT-210 | Terracotta pot | $12.50 | 60 | ||
| 6 | 2005 | SL-401 | 4 | Yes | PT-212 | Ceramic pot | $19.00 | 18 | ||
| 7 | 2006 | PL-104 | 1 | Yes | TL-301 | Watering can | $18.00 | 9 | ||
| 8 | 2007 | PT-212 | 2 | Yes | SL-401 | Potting mix | $7.25 | 80 | ||
| 9 | 2008 | PL-999 | 1 | No |
Every row shows Yes except D9, which shows No: order 2008's SKU, PL-999, isn't in the price list in column G.
Why it works
Checks whether the number of cells in $G$2:$G$8 whose value is equal to B2 is greater than 0. If it is, the result is "Yes"; if not, it's "No".
- 1. COUNTIF: Counts the cells in
$G$2:$G$8whose value is equal toB2. - 2. IF: Checks whether the result of step 1 is greater than
0. If it is, the result is"Yes"; if not, it's"No".
Row by row
Compare the budget and the actual spend on each row: IF(C2=D2, "Match", "Differs"). Equal numbers match whatever their format; text compares without regard to case.
=IF(C2=D2,"Match","Differs")Exactly, including capitals
The = comparison treats “MARA” and “mara” as equal. EXACT doesn't: IF(EXACT(A2, A4), "Same", "Different") tells the two sign-ups apart.
=IF(EXACT(A2,A4),"Same","Different")List only the differences
In Excel 2021 or later, Microsoft 365 and Google Sheets, FILTER can list the values of one column that are missing from the other in one formula: FILTER(B2:B9, COUNTIF($G$2:$G$8, B2:B9)=0) keeps the SKUs whose count in the price list is 0. On the sheet above it returns PL-999.
=FILTER(B2:B9,COUNTIF($G$2:$G$8,B2:B9)=0)When you need it
Comparing lists is one of the most common office jobs: reconciling an export against last month's, checking which invoices have been paid, finding customers who are in the CRM but not in the mailing list, or confirming that two systems agree row by row. Row-by-row comparison works when both lists are in the same order; when they aren't, use COUNTIF (or XLOOKUP) to check membership instead. Add a filter on the result column to see only the differences.
In Google Sheets
IF, COUNTIF and EXACT work the same in Google Sheets, so every formula on this page works there unchanged.
Common mistakes
Forgetting
$on the other list, so each row searches a shifted range.Extra spaces making identical-looking values differ: TRIM both sides first.
Numbers stored as text on one side, which never equal real numbers.
Sources
Official documentation the facts on this page were checked against.