DATA CLEANUP & ERROR CHECKS
Compare Two Lists in Excel: Find Matches, Missing Items and Differences
Two lists that should match rarely do: the customers in your CRM and in your billing system, the invoices in the ledger and on a supplier statement, last month’s price list and this month’s. This guide compares two lists in Excel with COUNTIF, cleans the hidden spaces that make matches fail, checks whether matching items agree, and lists what is missing from each side.

Quick answer
| Question | Formula |
|---|---|
| Is A5 anywhere in list B? | =IF(COUNTIF(B_list,A5)>0,"In both","Missing") |
| Ignore extra spaces and case | =UPPER(TRIM(A5)) on both lists, then compare the clean values |
| Same row, same value? | =IF(A5=H5,"Same","Different") (only when both lists are in the same order) |
| Return the matching value | =INDEX(B_names,MATCH(A5,B_ids,0)) or XLOOKUP |
Step 1: Put the two lists side by side
Copy each list onto the same sheet, with a gap column between them, so the formulas can reference both. The example compares 18 customers in a CRM with 16 in the billing system. The lists are in different orders, which is normal; the formulas below do not depend on order.

Step 2: Clean the IDs first
=IF(A5="","",UPPER(TRIM(A5)))
Most failed matches are caused by things you cannot see: a trailing space, a double space or a different case. In the example, billing has the ID typed as c-1013 with a space at the end. TRIM removes the extra spaces and UPPER makes the case consistent, so both lists contain C-1013. Without the clean step only 11 IDs match; with it, 12 do. For non-breaking spaces and other hidden characters that TRIM cannot remove, see remove extra spaces and hidden characters and find non-printing characters. If one list has numbers stored as text, convert them first.

Step 3: Flag matches and missing items with COUNTIF
=IF(C5="","",IF(COUNTIF($J$5:$J$40,C5)>0,"In both","Only in CRM"))
COUNTIF counts how many times the clean ID appears in the other list’s clean IDs. Zero means it is missing. The billing side uses the same formula pointed the other way:
=IF(J5="","",IF(COUNTIF($C$5:$C$40,J5)>0,"In both","Only in Billing"))
Result: 6 customers are only in the CRM (C-1004 Atlas Print Co. is the first) and 4 are only in billing (C-1021 to C-1024). The workbook also shades those rows with conditional formatting; the rule is =$D5="Only in CRM", the same idea as conditional formatting based on another cell. To find repeats within one list instead, see flag duplicate invoice numbers.

Step 4: Same ID, different details?
=IF(D5<>"In both","",IF(TRIM(B5)=TRIM(INDEX($I$5:$I$40,MATCH(C5,$J$5:$J$40,0))),"Name OK","Name differs"))
When an ID is in both lists, INDEX/MATCH pulls the other list’s name and compares it. C-1006 is Harbor Foods in the CRM and Harbour Foods in billing, so it shows Name differs. The same pattern compares prices, amounts or dates. XLOOKUP does the same job in Microsoft 365; see INDEX/MATCH vs XLOOKUP, and VLOOKUP not working if a lookup returns #N/A for an item you can see.

Step 5: Summary counts and a check
| Measure | CRM (list A) | Billing (list B) |
|---|---|---|
| Customers | 18 | 16 |
| In both lists | 12 | 12 |
| Only in this list | 6 | 4 |
The two In both counts must agree, and each list’s In both + Only in this list must equal its total. If they do not, one list has a duplicate ID. The summary also counts the name differences (1) and the matches you would get on the raw IDs without cleaning (11), which shows what the hidden space cost.

Step 6: List the missing items
=IFERROR(INDEX(Compare!$A$5:$A$40,MATCH(1,Compare!$F$5:$F$40,0)),"")
A helper column numbers each missing item with a running COUNTIF (1, 2, 3…), and INDEX/MATCH pulls item 1, item 2 and so on onto the Summary sheet. This works in every Excel version. In Microsoft 365 you can use one formula instead: =FILTER(A5:B40,D5:D40="Only in CRM"). These are the lists to send to whoever maintains each system. The same approach drives a bank reconciliation, which compares the bank statement with the cash book.

Other ways to compare two lists
- Conditional Formatting > Highlight Cells Rules > Duplicate Values on both columns: quick, but it cannot tell you which list an item is missing from.
- XLOOKUP or MATCH wrapped in ISNA: =ISNA(MATCH(A5,H:H,0)) returns TRUE when the item is missing. See how to use XLOOKUP.
- Power Query merge (Left Anti join) for very large lists or lists in different files.
- Remove Duplicates on a combined list to get the full set of unique items; see remove duplicate rows safely.
Common mistakes
- Comparing row by row when the lists are in different orders.
- Skipping the TRIM step and trusting a no-match result.
- Comparing names instead of IDs.
- Checking only one direction: items missing from list A are as important as items missing from list B.
- Numbers in one list and text in the other: 1001 and ‘1001 do not match.
Frequently asked questions
How do I compare two lists in Excel for matches?
Use =COUNTIF(other_list, A2)>0 next to each item. TRUE (or In both) means the item is in the other list.
How do I find items in one list that are not in another?
Filter for COUNTIF(other_list, A2)=0, or in Microsoft 365 use =FILTER(list, COUNTIF(other_list, list)=0).
Why does my comparison show no match when the values look the same?
Usually an extra space, a non-breaking space or a number stored as text. Clean both lists with TRIM (and CLEAN or SUBSTITUTE for CHAR(160)) before comparing.
Is COUNTIF case-sensitive?
No. Use EXACT inside SUMPRODUCT for a case-sensitive comparison.
How do I compare two lists on different sheets?
The same formulas work with sheet references, for example =COUNTIF(Billing!$A:$A, A2)>0.
Final checklist
- Both lists compared on a unique ID.
- IDs cleaned with TRIM and UPPER.
- Matches flagged in both directions.
- Details (names, amounts) checked for matched items.
- Summary check shows Ties.
- Missing lists sent to the owners of each system.
Clean data, faster
Find more ready-to-use Excel templates, learn the formulas in the OneXcel Tutorial Hub, or report the results with the OneXcel Dashboard Builder.