ListFerret mascot

Home › Guides › How to Compare Two Lists in Excel or Google Sheets

How to Compare Two Lists in Excel or Google Sheets and Find What’s Missing

You have two lists (customers this month and last month, SKUs in two systems, two mailing lists) and you need to know what is in one but not the other. This guide shows how to compare two lists in Excel and Google Sheets with formulas, conditional formatting and Power Query, explains why comparisons often report differences that are not real, and shows a no-formula method for when the lists are large or live in different places.

The three answers you want

When you compare two lists, A and B, there are three useful results: items only in A, items only in B, and items in both (the overlap). A fourth, the union, is every item from either list once. Everything below is a way to get one or more of these.

A worked example

Here are two made-up email lists. Notice that BEN@example.org is capitalised differently in list B, and carla@example.com has a trailing space (marked ␠ in the table):

List A (customers)List B (webinar attendees)
anna@example.com
ben@example.org
carla@example.com
dev@example.net
elena@example.org
farid@example.com
BEN@example.org
carla@example.com␠
gita@example.net
elena@example.org
hugo@example.com
The Compare Lists tool showing 3 items only in A, 3 in both, 2 only in B, a combined list of 8, and a similarity of 37.5 percent
The Compare Lists tool on the example lists, with case ignored and spaces trimmed. The data is invented for illustration.
ResultItemsCount
Only in Aanna@example.com, dev@example.net, farid@example.com3
In bothben@example.org, carla@example.com, elena@example.org3
Only in Bgita@example.net, hugo@example.com2
Union (all items once)the eight distinct addresses above8

The similarity score of 37.5% is the overlap divided by the size of the union: 3 ÷ 8. If case and spaces had been treated as significant, “ben” and “carla” would wrongly have shown up as differences, which is the most common reason a comparison looks wrong.

Method 1: COUNTIF (works in every version)

With list A in column A and list B in column B, put this in C2 and fill down:

=IF(COUNTIF($B$2:$B$500, A2)=0, "Only in A", "In both")

COUNTIF counts how many times the value in A2 appears in list B. Zero means it is missing. Repeat the idea in column D with the columns swapped to find what is only in B. COUNTIF ignores letter case, which is usually what you want.

Method 2: MATCH, VLOOKUP and XLOOKUP

=IF(ISNA(MATCH(A2, $B$2:$B$500, 0)), "Only in A", "In both")
=IF(ISNA(VLOOKUP(A2, $B$2:$B$500, 1, FALSE)), "Only in A", "In both")
=XLOOKUP(A2, $B$2:$B$500, $B$2:$B$500, "Only in A")

All three do the same job. XLOOKUP needs Excel 2021 or Microsoft 365 (and works in Google Sheets). The last argument of MATCH and VLOOKUP (0 and FALSE) means exact match; leave it out and you get approximate matching, which gives wrong answers on unsorted data.

Method 3: list the differences with FILTER

In Excel 365 and Google Sheets, one formula returns the whole list of items that are only in A:

=FILTER(A2:A500, COUNTIF(B2:B500, A2:A500)=0)

Swap the two ranges to get the items only in B. The result is a clean list you can copy, rather than a flag beside every row.

Method 4: highlight with conditional formatting

To see differences without adding columns, select list A, choose Conditional Formatting, then New Rule, then “Use a formula”, and enter =COUNTIF($B$2:$B$500, A2)=0 with a fill colour. Everything in A that is missing from B lights up. In Google Sheets the equivalent is Format, then Conditional formatting, with a “custom formula”. If instead you select both columns and use Home, Conditional Formatting, Highlight Cells Rules, Duplicate Values, the items that appear in both lists are highlighted.

Method 5: Power Query for big or repeated comparisons

In Excel, Power Query can do an “anti-join”, which is exactly “rows in A that are not in B”:

  1. Select each list and choose Data, then From Table/Range, so both are loaded as queries.
  2. Choose Home, then Merge Queries. Pick list A first and list B second, and select the key column in each.
  3. Set the join kind to Left Anti (rows only in first). The result is the items only in A.
  4. Choose Inner for the overlap, or switch the order for the items only in B.
  5. Load the result to a sheet. When the source data changes, Refresh All re-runs the comparison.

Comparing rows, not single values

If each row is identified by more than one column, such as first name and surname, make a combined key in a helper column, for example =A2&"|"&B2, and compare those keys. The separator stops "Ann" + "Marie Lee" from colliding with "Ann Marie" + "Lee". In Google Sheets, lists in different files can be pulled in with IMPORTRANGE("spreadsheet url", "Sheet1!A2:A500").

Why a comparison shows false differences

CauseExampleFix
Extra spaces“Apple” versus “Apple ”Wrap values in TRIM(), or trim before comparing
Case“apple” versus “Apple”COUNTIF and MATCH already ignore case; EXACT() does not
Numbers stored as textThe number 7 versus the text “7”Convert both columns to the same type
Leading zeros“007” versus “7”Decide which form is right and convert the other
Invisible charactersNon-breaking spaces from web pagesClean with SUBSTITUTE(A2, CHAR(160), " ")
Punctuation“Smith, J.” versus “Smith J”Strip punctuation before comparing, or use a tool that can ignore it

Performance on large lists

A formula in every row that searches the whole other list does a lot of work. With tens of thousands of rows it can make a workbook slow. Use bounded ranges ($B$2:$B$50000) rather than entire columns inside array formulas, prefer MATCH or XLOOKUP to COUNTIF on very long lists, or use Power Query, which is built for this.

The no-formula method

Copy each column and paste them into Compare Lists. It shows only in A, only in B, in both and the combined list at once, with options to ignore case, extra spaces, leading zeros and punctuation, so the false differences above disappear. You can compare on one column of CSV rows, copy any result straight back into your spreadsheet, or send a result into one of the lists to compare it against a third. The comparison happens in your browser, so nothing is uploaded.

Frequently asked questions

How do I find the differences between two columns in Excel?

Use =IF(COUNTIF($B$2:$B$500, A2)=0, "Only in A", "In both") beside list A, or =FILTER(A2:A500, COUNTIF(B2:B500, A2:A500)=0) in Excel 365 to return just the missing items.

How do I compare two lists in Google Sheets?

The same formulas work. =FILTER(A2:A500, COUNTIF(B2:B500, A2:A500)=0) lists everything in column A that is not in column B. Use IMPORTRANGE if the lists are in different spreadsheets.

Why does my comparison say items are different when they look identical?

Usually a trailing space, a different capitalisation or a number stored as text. Trim the values and make sure both columns use the same data type.

What is the quickest way to compare two lists without formulas?

Paste both lists into the Compare Lists tool. It shows items only in A, in both and only in B immediately, and lets you ignore case, spaces and leading zeros.

What does the similarity percentage mean?

It is the number of items in both lists divided by the number of distinct items across both lists. 100% means the lists contain exactly the same items, and 0% means they share nothing.

Try it now: use the free Compare Lists - private, instant and runs in your browser. Open Compare Lists →

More guides

Share this page: XFacebookLinkedInRedditEmail