How to Compare Two Lists in Excel
By ExcelReady TeamUpdated 5 min read
The short answer
To compare two lists in Excel, use COUNTIF to check whether each item in one list appears in the other: =IF(COUNTIF($C$2:$C$6,A2)>0,"Yes","No"). To list the missing items in one go, use FILTER with COUNTIF. To see the differences at a glance, add a conditional formatting rule that highlights items with no match.
Key takeaways
- COUNTIF(other_list, item) returns 0 when an item is missing, so it is the simplest way to compare lists.
- Lock the other list with $ signs before copying the formula down.
- FILTER with COUNTIF lists every missing item at once in Microsoft 365 and Excel 2021.
- Conditional formatting with a COUNTIF rule highlights the differences without extra columns.
- Hidden spaces make matching items look different, so clean both lists with TRIM first.
On this page+
To compare two lists in Excel, you check each item in one list against the other and flag the ones that are missing. COUNTIF does this in one short formula, FILTER pulls out every missing item at once, and conditional formatting highlights the gaps without any helper column. This guide shows all three on the same small example, plus how to compare lists row by row.
All the examples use an event sign-up list and an attendance list:
| A | B | C | |
|---|---|---|---|
| 1 | Registered | Attended? | Attended |
| 2 | Ana | Ben | |
| 3 | Ben | Dev | |
| 4 | Chloe | Ella | |
| 5 | Dev | Gus | |
| 6 | Ella | Ana | |
| 7 | Femi |
The question is simple: who registered but didn't come, and who came without registering?
Which method should you use?#
The right method depends on what you want to see. This table sums them up:
| You want | Method | Works in |
|---|---|---|
| A Yes/No flag next to each item | IF + COUNTIF | Every version |
| The matching value or a message | XLOOKUP | Excel 2021, Microsoft 365 |
| A separate list of missing items | FILTER + COUNTIF | Excel 2021, Microsoft 365 |
| Coloured cells, no formulas in the data | Conditional formatting | Every version |
| Lists in the same order, row by row | =A2=C2 or EXACT | Every version |
Compare two lists with COUNTIF#
COUNTIF counts how many times an item appears in the other list, so a result of 0 means the item is missing. In B2, type:
=IF(COUNTIF($C$2:$C$6,A2)>0,"Yes","No")Copy it down to B7 (Windows: Ctrl+D; Mac: ⌘D). You get Yes for Ana, Ben, Dev and Ella, and No for Chloe and Femi. Those two registered but didn't attend.
The $ signs lock the attendance list, so every row checks the same range. A2 has no $, so it moves down to A3, A4 and so on. If you only want the count, =COUNTIF($C$2:$C$6,A2) on its own is fine: 1 means found, 0 means missing, and 2 or more means the name appears twice. The COUNTIF guide with criteria examples explains the function in depth.
To check the other direction, put the same formula next to the second list with the ranges swapped: =IF(COUNTIF($A$2:$A$7,C2)>0,"Yes","No"). Gus gets No, because he attended without registering.
Compare lists with XLOOKUP#
XLOOKUP is useful when you want to bring back the matching value or show a clear message. In B2:
=XLOOKUP(A2,$C$2:$C$6,$C$2:$C$6,"Missing")Found names come back as themselves, and Chloe and Femi show Missing. The real power shows when the second list has more columns: change the return range to, say, a check-in time column, and you compare and fetch in one step. XLOOKUP needs Excel 2021 or Microsoft 365; see the XLOOKUP function guide for the syntax.
List the missing items with FILTER#
FILTER with COUNTIF gives you a clean list of everything missing, in one formula. In an empty cell, type:
=FILTER(A2:A7,COUNTIF(C2:C6,A2:A7)=0)The result spills into two cells: Chloe and Femi. Here COUNTIF checks all six names at once and returns 0 for the missing ones, and FILTER keeps only those.
Swap the ranges to see the other side: =FILTER(C2:C6,COUNTIF(A2:A7,C2:C6)=0) returns Gus. To count how many registered people attended, use =SUMPRODUCT(--(COUNTIF(C2:C6,A2:A7)>0)), which returns 4. FILTER needs Excel 2021 or Microsoft 365. Make sure the cells below are empty, or you'll get a #SPILL! error.
Highlight differences with conditional formatting#
Conditional formatting colours the missing items, so you can see the differences without adding columns. Here's how:
- Select A2:A7.
- Go to Home > Conditional Formatting > New Rule.
- Choose Use a formula to determine which cells to format.
- Enter
=COUNTIF($C$2:$C$6,A2)=0and pick a fill colour. - Click OK.
Chloe and Femi turn coloured. Write the formula for the first cell of your selection, A2, and Excel adjusts it for the rest.
For a quick look at items in both lists, select both columns and use Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. Every name that appears in both lists gets highlighted. This also flags repeats within one list, so use it for a fast check, not a final answer.
Compare two lists row by row#
If both lists are in the same order and you want to know whether each row matches, compare the cells directly:
=A2=C2This returns TRUE or FALSE for each row. It ignores capitals, so "ana" equals "Ana". When capitals matter, such as product codes, use =EXACT(A2,C2) instead, which is case-sensitive. Row-by-row checks are common for reconciling two exports of the same report.
Why matching items show as missing#
If an item you can see in both lists shows No or Missing, the two values aren't identical to Excel. The usual causes:
- Extra spaces. "Ben " with a trailing space doesn't match "Ben". Clean both lists with TRIM.
- Numbers stored as text. An ID of 1042 and the text "1042" don't match. Convert them so both are numbers.
- Different spellings. "Dev" and "Devendra" are different values. Agree on one version first.
These are the same issues that break lookups. The lookup errors practice has tasks built around them. For counting the distinct names after you compare, see how to count unique values. If you track sign-ups often, the attendance tracker walkthrough builds this check into a reusable sheet, and COUNTIF vs COUNTIFS explains when to compare on two columns at once. The COUNTIF function guide has a quick syntax reference.
Practise it#
Comparing lists is a very common task in data and operations job tests. Practise COUNTIF in a live spreadsheet: you type the formula, it checks the result instantly, and you learn the criteria rules that make list checks work. Then try the data analyst Excel mock test to compare and clean data under time pressure.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Did Chloe (in A4) attend? In B4, use IF and COUNTIF to show Yes if A4 appears in the Attended list C2:C6, and No if it doesn't.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Attended | |||
| 2 | Ana | Ben | ||
| 3 | Ben | Dev | ||
| 4 | Chloe | Ella | ||
| 5 | Dev | Gus | ||
| 6 | Ella | Ana | ||
| 7 | Femi | |||
| 8 | ||||
| 9 | ||||
| 10 |
Tip: COUNTIF(C2:C6,A4) counts how many times Chloe appears. If that is more than 0, show Yes.
Practise this in a lesson
Frequently asked questions
How do I compare two lists in Excel for matches?
Next to the first list, type =IF(COUNTIF($C$2:$C$6,A2)>0,"Yes","No") and copy it down. Yes means the item is also in the second list; No means it is missing.
How do I find items in one list but not the other?
In Microsoft 365 or Excel 2021, use =FILTER(A2:A7,COUNTIF(C2:C6,A2:A7)=0). It lists every item from the first list that doesn't appear in the second.
How do I highlight differences between two lists?
Select the first list, go to Home, Conditional Formatting, New Rule, and choose Use a formula. Enter =COUNTIF($C$2:$C$6,A2)=0 and pick a fill colour. Items missing from the second list light up.
Is comparing lists with COUNTIF case-sensitive?
No. COUNTIF treats Ana and ANA as the same. If capitals matter, compare matching rows with EXACT, which returns TRUE only when the text matches exactly, including case.
Why do matching items show as missing?
Usually one list has extra spaces or numbers stored as text. Clean both lists with TRIM, and make sure numbers are real numbers in both, then compare again.