formulastreak

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

Which ordered SKUs are in the price list? PL-999 isn't · edit D2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultD2 = Yes
ABCDEFGHIJ
1OrderSKUQtyIn price list?SKUProductPriceStock
22001PL-1042YesPL-101Fern$9.5040
32002PT-2101YesPL-104Monstera$34.0012
42003TL-3013YesPL-107Snake plant$22.0025
52004PL-1011YesPT-210Terracotta pot$12.5060
62005SL-4014YesPT-212Ceramic pot$19.0018
72006PL-1041YesTL-301Watering can$18.009
82007PT-2122YesSL-401Potting mix$7.2580
92008PL-9991No

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. 1. COUNTIF: Counts the cells in $G$2:$G$8 whose value is equal to B2.
  2. 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.

Practise IF on a live sheet

Lesson 33, Find duplicates (Unit 9, Data quality), has 4 graded exercises, checked instantly, with steps and hints when you're stuck. Pro