Excel library

How to Compare Two Columns in Excel (4 Easy Methods)

When you receive two inventory lists, email rosters, or invoice exports, scanning them by eye for missing or mismatched entries is slow and easy to get wrong. Excel can check every pair of cells side by side or search an entire second column in seconds and return a clear label such as Match, Mismatch, or Not Found. In this tutorial, I'll show you how to compare two columns in Excel using four reliable formulas.

Quick answer
  1. To compare two columns row by row, enter =IF(A2=B2,"Match","Mismatch") in cell C2 and copy it down.
  2. To check if a value in column A appears anywhere in column B, enter =IF(COUNTIF($B$2:$B$7,A2)>0,"Found","Not Found") in cell C2.

Use IF when both lists are already aligned row by row, and use COUNTIF when items appear in different rows.

Method 1: Compare Two Columns Row by Row Using the IF Function

Use this method when both columns are sorted in the same order and you want to check whether each row in column A equals the same row in column B. It works in every version of Excel and lets you choose any status label you prefer.

Our sample data is in A1:B7, with product codes in List A (column A) and List B (column B).

  1. Select cell C1 and type Status as the column header.
  2. Select cell C2 and type the IF formula below.
  3. Press Enter to evaluate the first row.
  4. Drag the fill handle at the bottom-right corner of C2 down through C7 to copy the formula to the remaining rows.
fxFormula
=IF(A2=B2,"Match","Mismatch")
IF formula in cell C2 comparing A2 and B2 row by row and returning Match or Mismatch across C2:C7
The IF formula compares A2:A7 and B2:B7 row by row, returning 4 matches and 2 mismatches

How this works: The expression A2=B2 tests whether the two cells in row 2 hold the same value. When the test is TRUE, IF returns Match; when it is FALSE, IF returns Mismatch. Across A2:B7, rows 2, 3, 5, and 7 return Match, while rows 4 and 6 return Mismatch. If you only need TRUE or FALSE without custom text, you can shorten the formula to =A2=B2.

Note: The equal sign (=) is not case-sensitive in Excel. That is why row 3 returns Match even though A3 contains SKU-102 and B3 contains sku-102. Leading or trailing spaces, however, will still trigger a mismatch.

Method 2: Compare Row by Row (Case-Sensitive) Using the EXACT Function

Use the EXACT function when capitalization matters, such as comparing case-sensitive product codes, IDs, or passwords on the same row. Unlike the equal sign, EXACT requires every character and letter case to be identical.

We will use the same product list in A1:B7, where row 3 has SKU-102 in A3 and lowercase sku-102 in B3.

  1. Select cell C1 and type Exact Match as the header.
  2. Select cell C2 and enter the formula below.
  3. Press Enter and inspect row 3 after copying the formula down.
  4. Drag the fill handle from C2 down to C7 to apply the check to every row.
fxFormula
=IF(EXACT(A2,B2),"Match","Mismatch")
EXACT formula wrapped in IF in cell C3 flagging SKU-102 and sku-102 as Mismatch because capitalization differs
EXACT catches the case difference in row 3 where SKU-102 does not match sku-102

How this works: EXACT(A2,B2) compares the two text strings character by character and returns TRUE only when spelling and capitalization match. Wrapping EXACT inside IF turns TRUE into Match and FALSE into Mismatch. Compared with Method 1, row 3 now flips to Mismatch, giving 3 matches and 3 mismatches overall.

Note: EXACT ignores number formatting such as currency symbols or decimal display settings, but it does treat extra spaces as differences. If your data comes from an external export, consider cleaning trailing spaces before comparing.

Method 3: Find Matches Anywhere in a Column Using the COUNTIF Function

Most real-world lists are not aligned row by row. Use COUNTIF when you want to check whether each item in column A exists anywhere in column B, regardless of which row it sits on.

In our table A1:B7, SKU-103 sits in A4 and also appears in B6, while SKU-105 in A6 does not appear anywhere in column B.

  1. Select cell C1 and enter In List B? as the header.
  2. Select cell C2 and type the COUNTIF formula below, making sure to lock $B$2:$B$7 with dollar signs.
  3. Press Enter to check the first product code.
  4. Copy the formula down through C7 to see which items from List A are missing from List B.
fxFormula
=IF(COUNTIF($B$2:$B$7,A2)>0,"Found","Not Found")
COUNTIF formula in cell C4 checking whether SKU-103 appears anywhere in B2:B7 and returning Found
COUNTIF checks each List A item against all of B2:B7, finding SKU-103 in row 6 and flagging SKU-105 as Not Found

How this works: COUNTIF($B$2:$B$7,A2) counts how many times the value in A2 appears anywhere inside B2:B7. If the count is greater than 0, IF returns Found; if the count is 0, it returns Not Found. In our example, C4 returns Found because SKU-103 exists in B6, leaving only SKU-105 in C6 marked as Not Found. Locking the range with $B$2:$B$7 keeps the lookup list fixed as you copy the formula down.

If you would rather highlight matches or differences visually with color instead of adding a helper column, you can also highlight duplicates in two columns with Conditional Formatting or find duplicate values using a formula.

Note: COUNTIF is not case-sensitive, so SKU-102 in A3 matches sku-102 in B3. Also note that this formula checks List A against List B; to find items that appear only in List B (such as SKU-108 in B4), run the same formula in column D with the ranges swapped: =IF(COUNTIF($A$2:$A$7,B2)>0,"Found","Not Found").

Method 4: Pull Matching Values Using VLOOKUP (or XLOOKUP)

Use VLOOKUP when you want the comparison column to return the actual matching value from column B rather than a generic status label. Wrapping it in IFERROR replaces missing-item errors with readable text.

Using the same dataset in A1:B7, we will search for each code in column A inside B2:B7 and return the match in column C.

  1. Select cell C1 and type Match as the header.
  2. Select cell C2 and enter the IFERROR and VLOOKUP formula below.
  3. Press Enter to return the first matching code.
  4. Drag the fill handle down to C7 to check the entire list.
fxFormula
=IFERROR(VLOOKUP(A2,$B$2:$B$7,1,FALSE),"Not Found")
IFERROR and VLOOKUP formula in cell C2 returning matching values from B2:B7 and Not Found for SKU-105
VLOOKUP with IFERROR returns each matching SKU from List B and shows Not Found for SKU-105

How this works: VLOOKUP(A2,$B$2:$B$7,1,FALSE) searches B2:B7 for an exact match (FALSE) to A2 and returns the value from column 1 of that range. Notice that row 3 returns sku-102 in lowercase because VLOOKUP pulls the exact text stored in B3. For SKU-105 in row 6, VLOOKUP returns #N/A, which IFERROR converts to Not Found.

XLOOKUP Alternative (Microsoft 365 and Excel 2021+)

If you use Microsoft 365 or Excel 2021 and later, XLOOKUP handles missing values natively without needing IFERROR:

fxFormula
=XLOOKUP(A2,$B$2:$B$7,$B$2:$B$7,"Not Found")

XLOOKUP defaults to an exact match and accepts the fallback text directly as its fourth argument. You can see more error-handling examples in our guide on using IFERROR with XLOOKUP.

FAQs

What is the fastest way to compare two columns in Excel?

For row-by-row checks, enter =A2=B2 in a helper column and copy it down to get instant TRUE or FALSE results. For unsorted lists where matches may sit on different rows, =IF(COUNTIF($B$2:$B$7,A2)>0,"Found","Not Found") is the quickest formula.

How do I compare two columns for exact case-sensitive matches?

Use the EXACT function: =IF(EXACT(A2,B2),"Match","Mismatch"). Unlike the equal sign, COUNTIF, or VLOOKUP, EXACT distinguishes between uppercase and lowercase letters.

Why does Excel say two identical-looking cells do not match?

The two most common causes are invisible leading or trailing spaces and mismatched data types, such as a number stored as text in one column and as a real number in the other. Use TRIM to strip extra spaces or convert both columns to the same data format before comparing.

How do I compare two columns of different lengths?

Use COUNTIF or VLOOKUP and lock the entire second column range with dollar signs, such as $B$2:$B$500. Then copy the formula down alongside every row in the first column so Excel checks each entry against the full second list.

Can I compare two columns located on different sheets?

Yes. Include the sheet name before the lookup range in any of these formulas, for example =IF(COUNTIF(Sheet2!$B$2:$B$7,A2)>0,"Found","Not Found"). If the sheet name contains spaces, wrap it in single quotes like 'Sales Data'!$B$2:$B$7.

Conclusion

For most people comparing two lists in Excel, COUNTIF is the best all-around choice because it finds matches even when rows are out of order and works in every Excel version. Use IF with = when both columns are already lined up row by row, switch to EXACT when capitalization matters, and reach for VLOOKUP or XLOOKUP when you want the matching value returned in the result column.