Home › Guides › How to Compare Two Lists in Excel or Google Sheets
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.
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.
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 |

| Result | Items | Count |
|---|---|---|
| Only in A | anna@example.com, dev@example.net, farid@example.com | 3 |
| In both | ben@example.org, carla@example.com, elena@example.org | 3 |
| Only in B | gita@example.net, hugo@example.com | 2 |
| Union (all items once) | the eight distinct addresses above | 8 |
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.
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.
=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.
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.
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.
In Excel, Power Query can do an “anti-join”, which is exactly “rows in A that are not in B”:
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").
| Cause | Example | Fix |
|---|---|---|
| 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 text | The 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 characters | Non-breaking spaces from web pages | Clean with SUBSTITUTE(A2, CHAR(160), " ") |
| Punctuation | “Smith, J.” versus “Smith J” | Strip punctuation before comparing, or use a tool that can ignore it |
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.
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.
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.
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.
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.
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.
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.