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.
- To compare two columns row by row, enter
=IF(A2=B2,"Match","Mismatch")in cell C2 and copy it down. - 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).
- Select cell C1 and type Status as the column header.
- Select cell C2 and type the IF formula below.
- Press Enter to evaluate the first row.
- Drag the fill handle at the bottom-right corner of C2 down through C7 to copy the formula to the remaining rows.
=IF(A2=B2,"Match","Mismatch")
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.
- Select cell C1 and type Exact Match as the header.
- Select cell C2 and enter the formula below.
- Press Enter and inspect row 3 after copying the formula down.
- Drag the fill handle from C2 down to C7 to apply the check to every row.
=IF(EXACT(A2,B2),"Match","Mismatch")
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.
- Select cell C1 and enter In List B? as the header.
- Select cell C2 and type the COUNTIF formula below, making sure to lock $B$2:$B$7 with dollar signs.
- Press Enter to check the first product code.
- Copy the formula down through C7 to see which items from List A are missing from List B.
=IF(COUNTIF($B$2:$B$7,A2)>0,"Found","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.
- Select cell C1 and type Match as the header.
- Select cell C2 and enter the IFERROR and VLOOKUP formula below.
- Press Enter to return the first matching code.
- Drag the fill handle down to C7 to check the entire list.
=IFERROR(VLOOKUP(A2,$B$2:$B$7,1,FALSE),"Not Found")
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:
=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?
How do I compare two columns for exact case-sensitive matches?
Why does Excel say two identical-looking cells do not match?
How do I compare two columns of different lengths?
Can I compare two columns located on different sheets?
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.