GUIDE · EXCEL

How to compare two lists in Excel for differences and matches

Two lists that should agree — customers in two systems, invoices billed against invoices paid, this month's accounts against last month's. Here is how to find what is missing, what matches and what is duplicated, with a formula for each.

The example layout

Every formula below assumes List A is in A2:A100 and List B is in B2:B100, with headings in row 1. Change the ranges to fit your data, and keep the dollar signs so the range stays fixed when you fill the formula down.

1. Find items in List A that are missing from List B

COUNTIF counts how many times a value appears in a range. A count of zero means the item is not in the other list. Put this in C2 and fill it down.

=IF(COUNTIF($B$2:$B$100,A2)=0,"Missing from B","")

To find what List B has that List A lacks, swap the two: =IF(COUNTIF($A$2:$A$100,B2)=0,"Missing from A","") in D2.

2. Mark the items that appear in both lists

The same test turned around. Anything counted at least once is a match.

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

3. Highlight the differences in place

Conditional formatting colours the cells without adding a column. Select A2:A100, then choose Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format. Enter the formula below, pick a fill colour and click OK.

Repeat for List B with the ranges swapped to highlight what only List B has.

=COUNTIF($B$2:$B$100,A2)=0

4. Pull the missing items into their own list

In Microsoft 365 and Excel 2021, FILTER returns every missing item in one formula, with no filling down. Put it in an empty cell with room below it.

=FILTER(A2:A100,(A2:A100<>"")*(COUNTIF(B2:B100,A2:A100)=0),"Nothing missing")

Older versions of Excel do not have FILTER. Use method 1 there, then filter column C for “Missing from B”.

5. Find where each item sits in the other list

XMATCH returns the position of a value in a range, and #N/A when it is not there. It is useful when you want to go on and fetch something from the matching row. It needs Microsoft 365 or Excel 2021; MATCH does the same job in older versions.

=IF(ISNA(XMATCH(A2,$B$2:$B$100,0)),"Missing from B","Row "&XMATCH(A2,$B$2:$B$100,0)+1)

6. Check each list for duplicates first

A value that appears twice in one list and once in the other still counts as a match in every method above. Check for duplicates within a list before you rely on the comparison.

=IF(COUNTIF($A$2:$A$100,A2)>1,"Duplicate","")

Why two lists that look the same do not match

Stray spaces
“INV-1001 ” with a trailing space is not “INV-1001”. Wrap the value in TRIM, or clean the column first: =TRIM(A2).
Numbers stored as text
A number in one list and the same digits stored as text in the other will not match. Convert the text with =VALUE(A2), or use Data → Text to Columns on the column.
Upper and lower case
COUNTIF, MATCH and XMATCH ignore case, so “abc” matches “ABC”. For a case-sensitive test use =SUMPRODUCT(--EXACT(A2,$B$2:$B$100))=0, which is TRUE when there is no exact match.
Wildcards
COUNTIF treats * and ? as wildcards. If your values contain them, use the SUMPRODUCT and EXACT formula above instead.

The same comparison in Sumlion

Sumlion is an AI assistant that runs in a side pane in Excel. Instead of building the formulas, describe the comparison. It reads both lists and reports what is missing from each side and what matches, with cell locations, and it deals with stray spaces and text-numbers along the way if you ask it to.

Compare the list in column A with the list in column B. Tell me which items are in A but not in B, which are in B but not in A, and which are duplicated within either list, with cell locations. Don't change any cells.
Type this into the Sumlion pane and edit the column references to fit your sheet.

Questions

What is the quickest way to compare two lists in Excel?
Put =IF(COUNTIF($B$2:$B$100,A2)=0,"Missing from B","") next to the first list and fill it down. It works in every version of Excel and shows at a glance which items the second list lacks.
How do I compare two lists on different sheets?
Use the same formulas with the sheet name in front of the range, for example =IF(COUNTIF(Sheet2!$A$2:$A$100,A2)=0,"Missing","").
How do I compare two lists and highlight the differences?
Select the first list, add a conditional formatting rule that uses the formula =COUNTIF($B$2:$B$100,A2)=0, and choose a fill colour. Items that are not in the second list are highlighted.
Can VLOOKUP compare two lists?
Yes. =IF(ISNA(VLOOKUP(A2,$B$2:$B$100,1,FALSE)),"Missing from B","") gives the same result as the COUNTIF method. COUNTIF is shorter and does not return an error when there is no match.

More guides

Try it on your own file.

Download Sumlion

Free to start. Works in Excel, Word and WPS.