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.

Excel comparison of a CRM customer list and a billing list showing 12 customers in both lists, 6 only in the CRM and 4 only in billing.
Two lists, three answers.

Quick answer

QuestionFormula
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
Free download: Get the compare-two-lists workbook (.xlsx). Paste list A in A5:B40 and list B in H5:I40; the flags, summary and missing lists update, and missing rows are shaded. No macros; works in Excel 2010 and later, Microsoft 365, Excel for the web and LibreOffice.

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.

Two Excel lists side by side: 18 CRM customers in columns A and B and 16 billing customers in columns H and I, in a different order.
List A and list B, different orders.
Compare on an ID: Compare on a unique key (customer ID, invoice number, SKU) rather than a name when you can. Names are typed differently in different systems; Step 4 shows how to check them separately.

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.

Excel Clean ID column using UPPER and TRIM, turning the billing ID c-1013 with a trailing space into C-1013 so it matches the CRM.
The hidden space costs one match.

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.

Excel COUNTIF columns flagging each customer as In both, Only in CRM or Only in Billing, with C-1004 only in the CRM and C-1021 only in billing.
Zero matches = missing.
Case: COUNTIF, MATCH and XLOOKUP ignore upper and lower case. If case matters (some product codes), use =SUMPRODUCT(–EXACT(A5,$H$5:$H$40))>0 instead.

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.

Excel name check using INDEX and MATCH that flags C-1006 because the CRM says Harbor Foods and billing says Harbour Foods.
One name typed two ways.

Step 5: Summary counts and a check

MeasureCRM (list A)Billing (list B)
Customers1816
In both lists1212
Only in this list64

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.

Excel comparison summary with 18 CRM customers, 16 billing customers, 12 in both lists, 6 only in the CRM, 4 only in billing, 1 name difference and a check that ties.
The check proves the comparison is complete.
Try it: On Compare type C-1004 in H21 and Atlas Print Co. in I21. In both rises from 12 to 13, Only in CRM falls from 6 to 5, C-1004 drops off the missing list and the check still shows Ties. Or change I9 to Harbor Foods: Names that differ falls to 0.

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.

Excel lists of the missing items: 6 customers missing from billing starting with C-1004 Atlas Print Co. and 4 missing from the CRM from C-1021 to C-1024.
What to add to each system.

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.
Workbook: Download the compare-two-lists workbook and paste in your own two lists.

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.