How to Compare Two Lists in Excel and Find Missing Records
Compare two lists in Excel for matches and, more usefully, find the records missing from either side — the COUNTIF, VLOOKUP, and XLOOKUP methods, where they break, and a reviewable way to reconcile both lists.
Ash RaiTechnical Product Manager, Data & Engineering
9 min read
Quick answer — how to compare two lists in Excel
Put both lists in the same workbook, then in a column beside List A enter =IF(COUNTIF(ListB, A2)=0, "Missing", "In both") and copy it down — every row now says whether that value also exists in List B. To catch records missing from either side, run the same check in both directions (List A against List B, then List B against List A), because a one-way check only finds what the first list is missing. On Excel 365 or 2021, =FILTER(ListA, COUNTIF(ListB, ListA)=0) spills a clean list of just the missing values; and for a reconciled count of both directions plus a downloadable result, an AI data analyst can return it from a plain-language request.
Comparing two lists is one of the most common jobs in Excel. You have customer IDs, SKUs, email addresses, or names in one place and a second list somewhere else, and you need to know which entries appear in both and which are missing from one side. That is a different job from comparing two entire Excel files cell by cell — matching every value, formula, and format across two whole workbooks — which takes a different approach. This guide is about comparing the values in two lists or columns: finding the matches, and, more usefully, finding the records that exist in one list but not the other.
The reliable answer is COUNTIF run in both directions, with a lookup when you also need to pull data across and conditional formatting when you'd rather see the differences than label them. What trips people up isn't the formula — it's forgetting the second direction, and trusting a comparison that quietly broke on a trailing space. Both are covered below, along with a downloadable route when the lists get long or need to leave Excel as a reconciled file.
01Compare two lists in Excel for matches
The quickest way to compare two lists for matches is COUNTIF. It counts how many times a value appears in a range, so if you point it at the other list, any count above zero means the value is a match. It takes two arguments — the range to search and the value to look for — and it doesn't care whether the lists are sorted or the same length.
Say List A sits in column A and List B in column D. In cell B2, beside the first value in List A, enter:
=IF(COUNTIF($D$2:$D$100, A2) > 0, "In both", "Only in A")
Copy it down List A. Every row now tells you whether that value also appears in List B. The dollar signs lock the List B range so it doesn't shift as you fill the formula down; if you'd rather read ListB than $D$2:$D$100, select the range and name it (Formulas → Define Name) and use the name instead. The method is identical whether your lists hold names, email addresses, numbers, or product codes — COUNTIF matches on the value itself. That single formula answers the head question, "how do you compare two lists in Excel for matches," for any list you can fit in a column.
02Find the missing records: in A not B, and in B not A
Finding matches is the easy half. The half people actually need is the missing records, and the trap is that one formula only looks one way. A COUNTIF check on List A tells you what List A has that List B is missing; it says nothing about the extra records sitting in List B. To reconcile two lists you have to run the comparison in both directions — this is what "cross compare two lists" really means.
Direction 1 — records in List A that are missing from List B. In a column beside List A:
=IF(COUNTIF($D$2:$D$100, A2) = 0, "Missing from B", "")
Direction 2 — records in List B that are missing from List A. Beside List B, flip the two ranges:
=IF(COUNTIF($A$2:$A$100, D2) = 0, "Missing from A", "")
Filter each column to its label and you have both halves of the exception report: everything that dropped out of List B, and everything that was added in List B. Run only the first and you'll miss the second entirely — a common reason a "compare" looks complete but isn't.
If you are on Excel 365 or Excel 2021, FILTER does this without helper columns and spills a clean list of only the missing values:
Run it once as written for the records in A not B, then once more with the two ranges swapped for the records in B not A. The result updates itself whenever a value inside those ranges changes — the advantage over the label-and-filter approach, with no re-dragging formulas or stale filters. One limit to know: a fixed range like A2:A100 won't pick up rows added below it, so put each list in an Excel Table (or use whole-column or dynamic ranges) if the data keeps growing. This is the same COUNTIF-plus-FILTER pattern the Excel formula references build their exception reports on.
03The formula toolkit: VLOOKUP, XLOOKUP, and where they break
COUNTIF answers is it there. When you also need to pull a value across from the matching row — an amount, a status, a date — you reach for a lookup. VLOOKUP is the one most people inherited; XLOOKUP is its modern replacement.
VLOOKUP, wrapped in IFNA so misses read cleanly instead of showing #N/A:
XLOOKUP, available in Excel 365 and 2021, does the same with less scaffolding and a built-in not-found argument:
=XLOOKUP(A2, $D$2:$D$100, $D$2:$D$100, "Missing")
"How to use VLOOKUP to compare two lists" is a common search, and VLOOKUP does work — but for a pure exists-or-missing check, COUNTIF is simpler, because you don't need a column to return. Reach for a lookup when you need the matching record's data, not just its presence.
The formulas are easy. What quietly ruins the result is the data, and these four failures are the usual reasons behind an "it doesn't work":
Duplicates. VLOOKUP and XLOOKUP return the first match and stop, so a repeated value hides silently; COUNTIF counts every occurrence, which is why a count can come back greater than one. Check both lists for duplicates before you trust a lookup.
Trailing spaces and nonprinting characters.CUST-1001 and CUST-1001 (with a trailing space) are not equal to Excel, and a single stray space or nonprinting character turns a real match into a false "missing." Wrap the values in TRIM (and CLEAN) to normalize them first. Case, on the other hand, isn't the trap: COUNTIF, VLOOKUP and XLOOKUP all ignore case, so CUST-1001 and cust-1001 already match — reach for EXACT only when you specifically want a case-sensitive comparison.
Text-versus-number IDs. If one list stores IDs as numbers and the other as text, that difference can cause a lookup to miss even though the values look identical on screen — how it behaves depends on the function, but VALUE-versus-text is a common mismatch. Convert one side with VALUE, or use Data → Text to Columns, so both are the same type.
Version. XLOOKUP and FILTER need Excel 365 or 2021. In Excel 2019 and earlier, fall back to VLOOKUP with IFNA, or MATCH wrapped in ISNA.
None of these are exotic. They're the ordinary reasons a comparison misfires, and they get harder to spot as the lists get longer. When you can't eyeball the rows anymore, a formula that's off by one trailing space is a quiet, expensive mistake.
Which method fits the job
What you need
Best method
Check whether each value exists in the other list
COUNTIF
A clean, self-updating list of only the missing values
FILTER + COUNTIF (Excel 365 / 2021)
Pull a value across from the matching row
XLOOKUP, or VLOOKUP + IFNA on older versions
Highlight the differences visually
Conditional formatting
Both directions, reconciled counts, downloadable result
An AI data analyst
Start from what you need out of the comparison, not from the formula you happen to know. For lists you can eyeball, the top four are enough; the last row is for when you need both directions, reconciled counts, inspectable logic, and a downloadable result.
04Compare by key with reconciled counts and a downloadable result
Formulas are fine for shorter lists you can eyeball. They get fragile when the lists are long, when both sides carry duplicates and formatting noise, or when you need the answer as a shareable file rather than a colored column. At that point the question stops being "which formula" and becomes "just tell me what's in one list and not the other, with the counts, as something I can hand over."
That is the job an AI data analyst does directly. In Anomaly you import each list as a table — List A as one upload, List B as a second — and ask in plain language:
"First, flag any customer_id that repeats within List A or within List B, and how many times. Then, comparing on the distinct IDs, show which are in A but not B, which are in B but not A, and how many are in both. Give me each result — and the duplicate counts — as downloadable tables."
Profiling the duplicates first matters because comparing two lists is a question about distinct membership — is this ID present or not — while a repeated value is a separate fact about one list. Anomaly runs the comparison in both directions on the distinct IDs — the anti-join that the two COUNTIF passes above do by hand — and returns the reconciled answer: the records only in A, the records only in B, and the overlap, with any within-list duplicate frequencies reported as their own result so a repeated value can't quietly change a count. Each result set is available to download as CSV, and on the result tiles that support it, a View calculation and View data control open the query it ran and the rows it returned, rather than leaving you to trust a spill range you can't see into.
Try it on the sample lists
Download List A and List B (13 and 12 customer IDs, 10 shared), upload both to an AI data analyst, and ask it to compare them. The figure below is the Summary sheet of the downloadable Excel workbook it returned from these exact files.
The two sample lists make it concrete: List A holds 13 customer IDs, List B holds 12, and they share 10. Run them through the workflow and it reconciles to exactly what you'd expect — 3 IDs only in List A (CUST-1001, CUST-1007, CUST-1013), 2 only in List B (CUST-1030, CUST-1033), and 10 in both.
Both lists reconciled from one plain-language request
First-party Anomaly AI product screenshot; figures are illustrative sample data from the two lists above. This is the Summary sheet of the downloadable Excel workbook, whose counts are live formulas over a separate ID Comparison sheet that lists the exact IDs (CUST-1001, CUST-1007, CUST-1013 only in List A; CUST-1030, CUST-1033 only in List B); the built-in checks confirm 3 + 10 = 13 in List A and 2 + 10 = 12 in List B.
Two honest notes. The two lists arrive as two separate tables, so the comparison is a question you ask across them, not something that happens at import — you upload both, then ask. And this fixture matched on clean IDs; if your real lists carry the whitespace or case noise described earlier, tell it to normalize the values (trim and lower) as part of the request. It isn't a native Excel feature and it isn't a real-time monitor — it's a way to get a reconciled, inspectable, downloadable answer from a plain request, which is exactly what the formula route makes you assemble by hand and re-run every time the lists change.
05Highlight matches or misses with conditional formatting
If you'd rather see the differences than label them, conditional formatting highlights them in place. Select both lists, go to Home → Conditional Formatting → Highlight Cells Rules → Duplicate Values, and switch the dropdown from Duplicate to Unique: Excel colors every value that appears in only one list — your missing records on both sides at once. One precondition: this reads cross-list membership cleanly only when neither list repeats values internally. If a list has its own duplicates, use the directional COUNTIF rule below instead, which asks the membership question — is this value in the other list? — rather than counting occurrences across the combined range. The distinct IDs the Unique rule leaves uncolored are the ones the two lists share, which also answers "compare two lists in Excel for duplicates."
To highlight the misses in just one list, select it, choose Conditional Formatting → New Rule → "Use a formula to determine which cells to format," and enter:
=COUNTIF($D$2:$D$100, A2) = 0
Anything in your list that isn't in the other one gets the format. It's the same COUNTIF logic as the label method, shown as color instead of text — handy for a quick visual scan, less so when you need to filter, count, or export the result. When the output has to be counted or shared, go back to the formulas or the downloadable route above.
FAQFrequently asked questions
How do you compare two lists in Excel?
Put both lists in the same workbook and use COUNTIF to check each value against the other list. Beside List A, enter =IF(COUNTIF(ListB, A2)=0, "Missing", "In both") and copy it down; every row shows whether that value also appears in List B. To find records missing from either side, run the check in both directions — List A against List B, then List B against List A — because a one-way check only finds what the first list is missing. On Excel 365 or 2021, =FILTER(ListA, COUNTIF(ListB, ListA)=0) returns a clean list of just the missing values.
What is the best way to compare two lists in Excel?
It depends on what you need out of it. For a simple exists-or-missing check, COUNTIF is the simplest and works in every version of Excel. When you need to pull a value across from the matching row, use XLOOKUP, or VLOOKUP with IFNA in older versions. For a clean, self-updating list of only the missing records, FILTER combined with COUNTIF is best on Excel 365 or 2021. Whichever you pick, compare in both directions and watch for duplicates, trailing spaces, and IDs stored as text in one list and as numbers in the other — those are the usual reasons a comparison looks wrong.
How do you compare two lists in Excel for duplicates?
"Duplicates" across two lists means the distinct values that appear in both — a membership check, not a frequency count. The safest way is a directional formula: =IF(COUNTIF(ListB, A2)>0, "In both", "Only in A") beside List A marks each value as shared or not. Conditional Formatting's Duplicate Values rule can highlight the shared values too, but it only reads membership cleanly when neither list repeats values internally; if you also need how many times a value appears, that frequency is a separate COUNTIF over one list. This is different from removing repeated rows inside a single list, which Excel's Remove Duplicates tool handles.
—The bottom line
The dependable way to compare two lists in Excel is COUNTIF in both directions — one pass to find what List A is missing, one to find what List B is missing — with XLOOKUP or FILTER when you need to pull data across or spill a clean result, and a careful check for duplicates and formatting before you trust any of it. That's enough for lists you can hold in one workbook. When the lists are long, messy, or need to leave Excel as a reconciled file someone else can check, describing the comparison in plain language gets you a two-direction answer — the missing records on each side, the counts documented, the logic and returned rows open to inspect, and each result set downloadable — rather than a colored column you assemble and re-run by hand.
Ash Rai is a Technical Product Manager with 5+ years of experience building AI and data engineering products, cloud and B2B SaaS products at early- and growth-stage startups. She studied Computer Science at IIT Delhi and Computer Science at the Max Planck Institute for Informatics, and has led data, platform and AI initiatives across fintech and developer tooling.