Compare two lists in Excel
To check whether the name in A2 is on a second list in D2:D5, use =ISNUMBER(MATCH(A2,$D$2:$D$5,0)). It shows TRUE if the name is on the list and FALSE if it isn't. Copy it down and you can see at a glance who's missing. It works in every version of Excel, on Windows and Mac; the FILTER and XLOOKUP ways below need Excel for Microsoft 365 or Excel 2021 onwards.
The ways at a glance
| You want | Formula | Works in |
|---|---|---|
| TRUE or FALSE: is it on the other list? | =ISNUMBER(MATCH(A2,$D$2:$D$5,0)) | Every version |
| Words instead, such as Missing | =IF(COUNTIF($D$2:$D$5,A2)>0,"On register","Missing") | Every version |
| Something from the other list, or Not found | =XLOOKUP(A2,$D$2:$D$5,$E$2:$E$5,"Not found") | 365, 2021 onwards |
| Just the missing names, as a list | =FILTER(A2:A5,COUNTIF(D2:D5,A2:A5)=0) | 365, 2021 onwards |
| The missing names coloured | A conditional formatting rule: =COUNTIF($D$2:$D$5,A2)=0 | Every version |
| Two copies of one list, row by row | =A2=D2 | Every version |
Each is worked through below, on a trip's bookings and its register.
Is it on the other list? MATCH and ISNUMBER
Everyone on a trip has to be on the register. You have the bookings in one list and the register in another, in a different order. Who has booked but isn't on the register?
By hand, you'd take each name in turn and look down the register for it. Amira is 3rd on the register, Ben is 1st, but Cara isn't there at all.
MATCH does exactly that. MATCH(A2,$D$2:$D$5,0) gives the position of the name on the register: 3 for Amira. When the name isn't there, it gives #N/A. ISNUMBER turns "a position" into TRUE and "#N/A" into FALSE.
=ISNUMBER(MATCH(A2,$D$2:$D$5,0))
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Booked | Position | On register? | Register |
| 2 | Amira | 3 | TRUE | Ben |
| 3 | Ben | 1 | TRUE | Dev |
| 4 | Cara | #N/A | FALSE | Amira |
| 5 | Dev | 2 | TRUE | Ewa |
A2is the name to look for.$D$2:$D$5is the other list, locked with $ so it doesn't slide down as you copy (see absolute references).0means an exact match. Leave it out and MATCH looks for the nearest match in a sorted list, which gives wrong answers.
The #N/A in B4 is the useful kind: it means the name really isn't there. The #N/A error explains it, and how to tell it apart from a name that's there with a hidden space.
Words instead of TRUE and FALSE: COUNTIF
COUNTIF counts how many times the name is on the other list. Amira is on the register once, so the count is 1; Cara isn't on it, so the count is 0. More than 0 means it's there. Put that inside IF to show words:
=IF(COUNTIF($D$2:$D$5,A2)>0,"On register","Missing")
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Booked | Count | Check | Register |
| 2 | Amira | 1 | On register | Ben |
| 3 | Ben | 1 | On register | Dev |
| 4 | Cara | 0 | Missing | Amira |
| 5 | Dev | 1 | On register | Ewa |
| 6 | Missing: | 1 |
A count of 2 or more tells you something else: the name is on the register twice. To find repeats within one list, see finding duplicates.
Bring something back, or Not found: XLOOKUP
Sometimes you want more than yes or no, such as the time each person signed in. XLOOKUP finds the name on the register and brings back the time from the next column, and its fourth part says what to show when the name isn't there.
=XLOOKUP(A2,$D$2:$D$5,$E$2:$E$5,"Not found")
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Booked | Signed in | Register | Time | |
| 2 | Amira | 8:52 | Ben | 8:41 | |
| 3 | Ben | 8:41 | Dev | 8:47 | |
| 4 | Cara | Not found | Amira | 8:52 | |
| 5 | Dev | 8:47 | Ewa | 8:55 |
In older Excel, =IFNA(VLOOKUP(A2,$D$2:$E$5,2,FALSE),"Not found") does the same, as long as the names are in the first column of the register. More in XLOOKUP.
Just the missing names, both ways: FILTER
In Excel 365 and 2021 onwards, FILTER can list only the missing names, and the list updates when either list changes. COUNTIF counts each booked name on the register, and FILTER keeps the ones where the count is 0.
=FILTER(A2:A5,COUNTIF(D2:D5,A2:A5)=0)
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Booked | Register | Booked, not on register | On register, not booked | ||
| 2 | Amira | Ben | Cara | Ewa | ||
| 3 | Ben | Dev | ||||
| 4 | Cara | Amira | ||||
| 5 | Dev | Ewa |
Cara has booked but isn't on the register, and Ewa is on the register but didn't book. The "None" at the end shows if nothing is missing, so you don't get #CALC!. See UNIQUE and FILTER for more.
Colour the missing names
To colour the missing names instead, select A2:A5, then go to Home › Conditional Formatting › New Rule and choose Use a formula to determine which cells to format. On a Mac, in the New Formatting Rule box, set Style to Classic first, then choose that option. Type =COUNTIF($D$2:$D$5,A2)=0 and pick a fill colour. The list stays locked with $, and A2 has none, so each cell checks its own name. More in conditional formatting with a formula.
Two copies of one list, row by row
If both lists are in the same order, such as last month's staff list and this month's, you only need to compare each row with the same row of the other: =A2=D2. EXACT does the same but also checks capital letters.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Last month | Same? | Exact? | This month |
| 2 | Amira Khan | TRUE | TRUE | Amira Khan |
| 3 | Ben Lewis | TRUE | FALSE | Ben lewis |
| 4 | Cara Doyle | FALSE | FALSE | Cara Boyle |
| 5 | Dev Shah | TRUE | TRUE | Dev Shah |
This is useless when the order is different: one extra name near the top and every row below it says FALSE. For lists in different orders, use MATCH or COUNTIF from above.
Common mistakes
Names further down all show FALSE
The other list wasn't locked, so it slid down as the formula was copied. By the bottom row it's looking at empty cells. Use $D$2:$D$5.
A name that's there shows FALSE
"Ben" and "Ben " (with a space) aren't the same to Excel, and neither are "Ben Lewis" and "Benjamin Lewis". Tidy both lists with TRIM, and compare on an ID number if you have one. An ID stored as a number on one list and as text on the other won't match either. These are the same causes that stop a lookup: VLOOKUP not working has a sheet for each.
Wrong answers from MATCH
Without the 0 at the end, MATCH looks for the nearest match in a sorted list, so it can say a name is there when it isn't. Always end with ,0).
The lists are on different sheets
That's fine: put the sheet name in front of the other list, as in =ISNUMBER(MATCH(A2,Register!$A$2:$A$40,0)). Clicking across to the other sheet while you type writes it for you; see lookups from another sheet.
Try it now
E2:E9 lists the people who have done first aid training. In B2, show TRUE if the person in column A is on that list and FALSE if not. Your formula will be copied down to B16.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Employee | Trained? | Completed first aid | ||
| 2 | Sunil Hall | Owen Price | |||
| 3 | Jordan Hughes | Nia Hughes | |||
| 4 | Dev Ali | Ollie Walker | |||
| 5 | Ivan Bennett | Hannah Clarke | |||
| 6 | Nia Hughes | Sam Turner | |||
| 7 | Sam Turner | Rachel Green | |||
| 8 | Hannah Clarke | Dev Ali | |||
| 9 | Ollie Walker | Lucy Shah | |||
| 10 | Grace Patel | ||||
| 11 | Tom Baker | ||||
| 12 | Maria Evans | ||||
| 13 | Femi Jones | ||||
| 14 | Chen Wright | ||||
| 15 | Lucy Shah | ||||
| 16 | Owen Price |
Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.
Part of Excel lookup functions practice: every lesson on the topic, with a project in Excel.
Where it works
MATCH, ISNUMBER, COUNTIF and conditional formatting work in every version of Excel on Windows and Mac, and in Excel for the web. XLOOKUP and FILTER need Excel for Microsoft 365, or Excel 2021 or later.
Questions
How do I compare two lists in Excel to find what's missing?
Next to the first list, use =ISNUMBER(MATCH(A2,$D$2:$D$40,0)) and copy it down: FALSE marks each name that isn't on the second list. Filter that column for FALSE to see them together. In Excel for Microsoft 365 or 2021 onwards, =FILTER(A2:A40,COUNTIF(D2:D40,A2:A40)=0) lists the missing names in one go. Swap the two lists round to find what's missing from the other side.
How do I compare two columns in Excel for matches?
It depends on the order. If the two columns are copies of one list in the same order, =A2=D2 checks each row against the same row of the other, and EXACT also checks capital letters. If the order is different, check each value against the whole of the other column with =COUNTIF($D$2:$D$40,A2)>0, which gives TRUE wherever the value appears.
How do I highlight the names that are on both lists?
Select the first list, then Home › Conditional Formatting › New Rule › Use a formula to determine which cells to format. On a Mac, set Style to Classic first. Type =COUNTIF($D$2:$D$40,A2)>0 and pick a colour. Use =0 at the end instead to colour the names that are missing from the other list.
Why does a name show as missing when it's on both lists?
The two copies aren't quite the same. Most often one has a space at the end, which =LEN(A2) shows by counting one character more than you can see. Tidy both lists with TRIM. Other causes are a different spelling, a middle name on one list, or an ID stored as a number on one list and as text on the other. Capital letters don't matter to MATCH or COUNTIF.