Tutorial

How to Compare Two Lists in Excel (Find Matches and Differences)

By 12 min read

Comparing two lists is one of the most common jobs in Excel: reconciling stock against sales, checking which customers from last year bought again, or finding which email addresses are missing from a mailing list. Checking row by row by eye is slow and error-prone – Excel has better tools for each kind of comparison.

This guide shows nine methods, from a two-click highlight to formulas that extract every match into a new list. All examples assume List A is in A2:A100 and List B is in B2:B100, with headers in row 1. Adjust the ranges to your data.

Need the answer once and fast? Paste both columns into the free Compare Two Lists tool – it shows items only in A, only in B and in both, without any formulas.


1. Highlight duplicates with conditional formatting (fastest)

Use this for a quick visual check of which values appear in both lists.

  1. Select both columns, for example A2:B100.
  2. Go to Home → Conditional Formatting → Highlight Cells Rules → Duplicate Values.
  3. Keep Duplicate to color the matches, or switch to Unique to color the values that appear only once.

Pros: two clicks, no formulas. Cons: it only colors cells – and a value repeated inside one list is highlighted as well, even if it isn't in the other list.


2. Highlight matches or differences with a formula rule

A formula rule only looks at the other list, so it doesn't have the problem above.

  1. Select A2:A100.
  2. Go to Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format.
  3. To highlight values of A that also appear in B, enter:
=COUNTIF($B$2:$B$100,$A2)>0
  1. To highlight values of A that are missing from B, use this instead:
=COUNTIF($B$2:$B$100,$A2)=0
  1. Click Format, pick a fill color and confirm. Repeat with the ranges swapped to color List B.

The $ signs matter: $B$2:$B$100 stays fixed while $A2 moves down one row for each cell.


3. Mark each item as "Match" or "No match" (COUNTIF or MATCH)

When you want a result you can filter and sort, add a helper column. In C2 enter:

=IF(COUNTIF($B$2:$B$100,A2)>0,"Match","No match")

MATCH does the same and stops at the first hit, which is a little faster on long lists:

=IF(ISNUMBER(MATCH(A2,$B$2:$B$100,0)),"Match","No match")

Fill the formula down, then use Data → Filter on column C to show only matches or only differences. Replace "Match" with COUNTIF(...) alone if you also want to know how many times each value appears in List B.


4. Find matches and return related data (VLOOKUP or XLOOKUP)

If List B has extra columns – say, prices in column C – a lookup tells you whether there is a match and brings back the related value.

With XLOOKUP (Excel 365 and Excel 2021 or later):

=XLOOKUP(A2,$B$2:$B$100,$C$2:$C$100,"Not found")

With VLOOKUP (all versions):

=IFERROR(VLOOKUP(A2,$B$2:$C$100,2,FALSE),"Not found")

Always use FALSE (exact match) in VLOOKUP when comparing lists; otherwise Excel may return the wrong row. XLOOKUP is exact by default, can look to the left, and has a built-in "not found" value.


5. Extract all matches or differences into a new list (FILTER)

In Excel 365 and Excel 2021, one formula can return the complete list of matches – it spills into the cells below automatically.

Values of A that are also in B:

=FILTER(A2:A100,COUNTIF(B2:B100,A2:A100)>0,"No matches")

Values of A that are not in B:

=FILTER(A2:A100,COUNTIF(B2:B100,A2:A100)=0,"No differences")

Wrap the result in UNIQUE() to remove duplicates and SORT() to sort it, for example =SORT(UNIQUE(FILTER(...))). Swap the ranges to get the values that are only in B.


6. Compare two columns row by row

Sometimes the question is not "is this value anywhere in the other list?" but "is row 5 the same in both columns?". Then compare cell by cell:

=IF(A2=B2,"Same","Different")

The = comparison ignores case ("Apple" equals "apple"). For a case-sensitive check, use EXACT:

=IF(EXACT(A2,B2),"Same","Different")

To highlight the differing rows instead, select A2:B100 and add a conditional formatting rule with the formula =$A2<>$B2.


7. Advanced Filter (extract differences in older Excel)

Without FILTER, Advanced Filter can copy the values that are missing from the other list:

  1. In an empty cell, for example E2, enter the criteria formula =COUNTIF($B$2:$B$100,A2)=0. Leave E1 empty or give it a label that is not a column header.
  2. Select A1:A100 (including the header) and go to Data → Advanced.
  3. Choose Copy to another location, set Criteria range to E1:E2 and Copy to to an empty cell.
  4. Click OK. Use >0 instead of =0 in step 1 to copy the matches.

8. Power Query (large or recurring comparisons)

For tens of thousands of rows, or comparisons you repeat every week, Power Query is the most robust option.

  1. Turn each list into a table (Insert → Table).
  2. Select one table and choose Data → From Table/Range; repeat for the other table.
  3. In Power Query, choose Home → Merge Queries, select both tables and the column to compare.
  4. Pick the Join Kind:
    • Inner – items in both lists (matches)
    • Left Anti – items only in the first list
    • Right Anti – items only in the second list
    • Full Outer – everything, with blanks where there is no match
  5. Click Close & Load. When the source data changes, Data → Refresh All updates the result.

9. Legacy array formula (Excel 2019 and earlier)

Without FILTER, this array formula lists the values of A that are not in B, one per row. Enter it in C2 with Ctrl+Shift+Enter, then fill it down:

=IFERROR(INDEX($A$2:$A$100,SMALL(IF(COUNTIF($B$2:$B$100,$A$2:$A$100)=0,ROW($A$2:$A$100)-ROW($A$2)+1),ROWS($C$2:C2))),"")

It works, but it is hard to read and slow on large ranges. If you have Excel 365, use FILTER (method 5) instead.


Why don't my lists match? Common problems

  • Extra spaces: "Apple " and "Apple" are different values. Clean the data with =TRIM(A2) first.
  • Numbers stored as text: 123 and "123" don't match. Use Data → Text to Columns → Finish or =VALUE(A2) to convert them.
  • Case: COUNTIF, MATCH, VLOOKUP and XLOOKUP ignore case. Only EXACT is case-sensitive.
  • Slow workbooks: whole-column references such as B:B in thousands of formulas slow Excel down. Limit the ranges, or use a table.

Summary: which method should you use?

Method Excel version Result Best for
Duplicate Values highlight All Colors cells Quick visual check
Formula conditional formatting All Colors matches or differences Accurate highlighting
COUNTIF / MATCH helper column All Match / No match flag Filtering and counting
XLOOKUP / VLOOKUP XLOOKUP: 365, 2021+ Returns related data Matches with extra columns
FILTER 365, 2021+ New list of matches or differences Extracting results
Row-by-row (= / EXACT) All Same / Different per row Aligned columns
Advanced Filter All Copied list Extraction in older Excel
Power Query 2016+ Refreshable table Large or recurring jobs
Array formula All List of differences Older Excel without FILTER

For most everyday tasks, a COUNTIF helper column or a formula-based highlight is enough. Use XLOOKUP when you need data from the other list, FILTER when you want the matches as a separate list, and Power Query for large or recurring comparisons. And if the data isn't in Excel yet, the online list comparison tool gives you the same answer without any formulas.

Tags

#Excel#List Comparison#XLOOKUP#Tutorial

About the author

songshiqiangIndependent developer

Builds fun websites with AI tools.

Related Posts

Tutorial

How to Compare Two Lists in Google Sheets (Matches and Differences)

Compare two lists in Google Sheets with conditional formatting, COUNTIF, MATCH, XLOOKUP and FILTER: highlight matches, flag missing items, extract differences into a new list, and compare lists on different sheets.

9 min read
#Google Sheets#List Comparison#Tutorial
Read More
Tutorial

How to Compare Two Lists in Java (Common, Missing and Equal Elements)

Compare two lists in Java: check equality with or without order, find common elements with retainAll, find differences with removeAll or streams, compare lists of objects, and avoid the most common performance trap.

10 min read
#Java#List Comparison#Tutorial
Read More
Tutorial

How to Create a Dropdown List in Excel

Detailed tutorial: From basics to advanced, learn to create dynamic dropdown lists and multi-level cascading options to make data entry more efficient and accurate.

8-minute read
#Excel#Dropdown List#Data Validation#Tutorial
Read More