How to Find Duplicates in Google Sheets but Ignore Blank Cells: Highlight, Count, List and Remove Without Empty Rows Getting in the Way (2026)
The standard duplicate formulas in Google Sheets have one annoying habit: they treat empty cells as values. An empty cell matches every other empty cell, so a highlight rule colors the whole unused part of the column, a duplicate count comes out in the hundreds, UNIQUE returns a blank line, and Remove duplicates deletes rows just because their email cell is empty. This guide shows the small change that fixes each of these, how to deal with cells that only look empty, and what to do when the column you check is often blank.
The short answer
- Highlighting: add a not-empty test to the rule,
=AND(A2<>"", COUNTIF($A$2:$A, A2)>1), applied to A2:A with Format › Conditional formatting › Custom formula is. - Formulas: drop blanks before you count or list, for example
=UNIQUE(TOCOL(A2:A, 1))instead of=UNIQUE(A2:A), and=SUMPRODUCT((A2:A<>"")*(COUNTIF(A2:A, A2:A)>1))to count duplicate rows. - Remove duplicates: blanks in a ticked column are compared like any other value. Give each blank row its own helper value first (see below) so those rows survive.
The example
A sign-up list. Most people left an email; some only left a phone number. Row 8 looks empty in column A but actually contains a single space, a common leftover from copy-pasting.
| Row | A: Email | B: Name | C: Phone |
|---|---|---|---|
| 2 | ana@example.com | Ana | (blank) |
| 3 | (blank) | Ben | 555-0101 |
| 4 | cara@example.com | Cara | 555-0199 |
| 5 | (blank) | Dev | 555-0102 |
| 6 | ANA@example.com | Ana R. | (blank) |
| 7 | (blank) | Ben C. | 555-0101 |
| 8 | (one space) | Eli | 555-0103 |
| 9 | cara@example.com | Cara | 555-0199 |
The real duplicates by email are Ana (rows 2 and 6; COUNTIF ignores letter case, so ANA@example.com matches) and Cara (rows 4 and 9). Rows 3, 5 and 7 have no email at all, and they aren’t duplicates of each other: they’re three different people.
Why blank cells show up as duplicates
The usual highlight rule is:
=COUNTIF($A$2:$A, A2)>1
For A3, the criterion is an empty cell, and COUNTIF counts the other empty cells in $A$2:$A as matches. On the example A3, A5 and A7 light up next to the real duplicates, and because the rule is applied to the open range A2:A, so does every empty cell below row 9. The same thing happens in a helper column (=COUNTIF($A$2:$A, A2) shows a large number on blank rows) and in any count built on it. The single space in A8 is unique, so it stays uncolored here, but keep it in mind; it comes back later.
Highlight duplicates but skip empty cells
- Select A2:A (the column without the header).
- Choose Format › Conditional formatting.
- Under Format rules, open Format cells if… and choose Custom formula is.
- Enter the formula below, pick a fill color under Formatting style, and click Done.
=AND(A2<>"", COUNTIF($A$2:$A, A2)>1)
A2<>"" is FALSE for an empty cell, so AND returns FALSE before the count matters. On the example only A2, A4, A6 and A9 are colored. To color the whole row instead, select A2:C and lock the column letters:
=AND($A2<>"", COUNTIF($A$2:$A, $A2)>1)
The cell in the formula (A2) must be the top-left cell of the range you selected, or the colors shift by a row. More rule variations, such as coloring only the second and later copies, are in the highlight duplicates guide. If you use a helper column instead of colors, the same idea is:
=IF(A2="", "", COUNTIF($A$2:$A, A2))
Cells that only look empty
Two kinds of cells cause trouble:
- Spaces. A cell containing a space is not empty, so
A2<>""is TRUE and two such cells count as duplicates of each other. If row 7 also held a single space instead of being empty, A7 and A8 would both be colored by the rule above. Either clean the column with Data › Data cleanup › Trim whitespace (it removes leading and trailing spaces, so a cell holding only spaces ends up empty), or make the test ignore spaces:
=AND(LEN(TRIM(A2))>0, COUNTIF($A$2:$A, A2)>1)
- Formulas that return "". A formula such as
=IF(B2="", "", B2)shows nothing.A2<>""treats it as empty, which is what you want, butISBLANK(A2)returns FALSE because the cell contains a formula. That’s why this guide usesA2<>""and not ISBLANK.
Zeros are values, not blanks: if your sheet uses 0 to mean “nothing”, add A2<>0 to the AND as well.
Counts, lists and filters without blanks
Every formula below skips empty cells. Results are for the example (column A, rows 2 to 9, with empty rows below):
| Goal | Ignores blanks | On the example |
|---|---|---|
| Highlight repeated emails | =AND(A2<>"", COUNTIF($A$2:$A, A2)>1) | A2, A4, A6, A9 |
| Count rows that are duplicates | =SUMPRODUCT((A2:A<>"")*(COUNTIF(A2:A, A2:A)>1)) | 4 |
| Count extra copies | =ARRAYFORMULA(ROWS(TOCOL(A2:A, 1)) - ROWS(UNIQUE(LOWER(TOCOL(A2:A, 1))))) | 2 |
| Each email once | =UNIQUE(TOCOL(A2:A, 1)) | 4 entries (ANA and the space are separate) |
| Repeated emails, once each | =ARRAYFORMULA(LET(u, UNIQUE(LOWER(TOCOL(A2:A, 1))), FILTER(u, COUNTIF(A2:A, u)>1))) | ana@example.com, cara@example.com |
| Show the duplicate rows | =FILTER(A2:C, A2:A<>"", COUNTIF(A2:A, A2:A)>1) | rows 2, 4, 6, 9 |
Count duplicates
To count the rows whose email appears more than once:
=SUMPRODUCT((A2:A<>"")*(COUNTIF(A2:A, A2:A)>1))
Without the (A2:A<>"") part, =SUMPRODUCT(--(COUNTIF(A2:A, A2:A)>1)) also counts every empty row in A2:A, so on a 1,000-row tab the answer is close to 1,000 instead of 4. For the number of extra copies (the rows Remove duplicates would delete), subtract the number of different values from the number of filled cells:
=ARRAYFORMULA(ROWS(TOCOL(A2:A, 1)) - ROWS(UNIQUE(LOWER(TOCOL(A2:A, 1)))))
Here 5 filled cells (including the space in A8) minus 3 different values gives 2: the ANA row and the second Cara row. TOCOL with 1 skips empty cells (Google’s TOCOL help), and LOWER is there because UNIQUE is case-sensitive while COUNTIF is not. Counting duplicates explains why different “how many duplicates” numbers disagree.
Get each value once, without the blank line
=UNIQUE(A2:A) returns 5 rows on the example: ana@example.com, an empty entry, cara@example.com, ANA@example.com and the space. Either of these drops the empty entry:
=UNIQUE(TOCOL(A2:A, 1))
=UNIQUE(FILTER(A2:A, A2:A<>""))
To also merge letter case and ignore cells that hold only spaces, which returns just ana@example.com and cara@example.com:
=ARRAYFORMULA(UNIQUE(LOWER(TRIM(FILTER(A2:A, LEN(TRIM(A2:A))>0)))))
Google’s UNIQUE help covers the function itself; UNIQUE vs Remove duplicates compares it with the menu tool.
List the repeated values, or show the duplicate rows
Each repeated email once:
=ARRAYFORMULA(LET(u, UNIQUE(LOWER(TOCOL(A2:A, 1))), FILTER(u, COUNTIF(A2:A, u)>1)))
Every row whose email is repeated (rows 2, 4, 6 and 9 on the example):
=FILTER(A2:C, A2:A<>"", COUNTIF(A2:A, A2:A)>1)
FILTER keeps a row only when all its conditions are TRUE, so A2:A<>"" keeps the blank rows out (Google’s FILTER help). More variations are in show only duplicates.
When the column you check is often blank
Ignoring blanks has a cost: rows without an email are never compared at all. In the example, Ben (row 3) and Ben C. (row 7) are probably the same person, because they left the same phone number, but the email check can’t see that. You have two options.
Only compare rows where every key column is filled
If a duplicate means “same name and same phone”, require both to be present. Applied to A2:C:
=AND($B2<>"", $C2<>"", COUNTIFS($B$2:$B, $B2, $C$2:$C, $C2)>1)
On the example only the two Cara rows match. Without $C2<>"", two rows with the same name and no phone would match each other through their empty phone cells. Google’s COUNTIFS help describes the range/criterion pairs, and duplicates across multiple columns covers multi-column checks in detail.
Fall back to another column
Often the better question is “same email, or same phone when there’s no email”. Build that key in a helper column D. Put this in D2 and fill it down:
=IF(LEN(TRIM(A2))>0, LOWER(TRIM(A2)), IF(LEN(TRIM(C2))>0, "tel:"&TRIM(C2), ""))
or fill the whole column from D2 at once:
=ARRAYFORMULA(IF(LEN(TRIM(A2:A))>0, LOWER(TRIM(A2:A)), IF(LEN(TRIM(C2:C))>0, "tel:"&TRIM(C2:C), "")))
The “tel:” prefix stops a phone number from ever matching an email, LEN(TRIM()) treats the space in A8 as empty, and a row with neither email nor phone gets an empty key. Then highlight rows with a repeated key (applied to A2:D):
=AND($D2<>"", COUNTIF($D$2:$D, $D2)>1)
| Row | Name | D: Key | Duplicate? |
|---|---|---|---|
| 2 | Ana | ana@example.com | yes (row 6) |
| 3 | Ben | tel:555-0101 | yes (row 7) |
| 4 | Cara | cara@example.com | yes (row 9) |
| 5 | Dev | tel:555-0102 | no |
| 6 | Ana R. | ana@example.com | yes (row 2) |
| 7 | Ben C. | tel:555-0101 | yes (row 3) |
| 8 | Eli | tel:555-0103 | no |
| 9 | Cara | cara@example.com | yes (row 4) |
Ben and Ben C. are now caught, and Dev and Eli are correctly left alone. Phone numbers typed in different formats (555-0101 vs 5550101) won’t match; duplicates that don’t match exactly shows how to normalize them.
Remove duplicates without deleting rows that have a blank
If you select A1:C9, choose Data › Data cleanup › Remove duplicates and tick only Email, the tool compares the empty email cells like any other value: row 3 is kept as the “first” blank and rows 5 (Dev) and 7 (Ben C.) are deleted along with the real duplicates in rows 6 and 9. Four rows remain, and two of the people you lost were never duplicates. Google’s Remove duplicates help describes the tool; the fix is to give each blank row a value nobody else has.
Option 1: a helper column, then Remove duplicates
- Right-click the tab and choose Duplicate, so you have a backup.
- Type a header such as Key in D1. In D2, enter the formula below and fill it down to the last row of data.
- Copy column D and paste it over itself with Edit › Paste special › Values only, so the helper values no longer change when rows are deleted.
- Select the table including the header and the helper column, choose Data › Data cleanup › Remove duplicates, tick Data has header row, and tick only the helper column. Click Remove duplicates.
- Delete the helper column.
=IF(LEN(TRIM(A2))>0, A2, "blank row "&ROW())
Each blank (or spaces-only) email becomes blank row 3, blank row 5 and so on, which never match each other. On the example rows 6 and 9 are removed and rows 2, 3, 4, 5, 7 and 8 stay. To also merge the Ben rows by phone, use the fallback key from the previous section as the helper instead.
Option 2: a cleaned copy with a formula
To leave the original alone, enter this on a new tab (copy the header row into row 1 and put the formula in A2):
=FILTER(A2:C, LEN(A2:A&B2:B&C2:C)>0, (LEN(TRIM(A2:A))=0)+(COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A))=1))
The first condition drops completely empty rows; the second keeps a row if its email is empty or if it’s the first time that email appears (the running COUNTIFS only looks at rows up to the current one). It returns the same six rows as Option 1 and updates as the list changes. To keep the newest row instead of the first, see keep the latest row; to run the cleanup on a schedule, see remove duplicates automatically.
Pitfalls
- Colors are off by one row. The formula’s cell (A2) must be the first cell of the “Apply to range”. If the range starts at A1, write the formula for A1.
- The header counts as a value. Start ranges at row 2, or a data value that equals the header text gets flagged.
- Two “empty” cells still match. At least one contains a space or another invisible character. Use the LEN(TRIM()) version or run Trim whitespace.
- Values that look the same don’t match. COUNTIF ignores letter case but not spaces inside or around the text; trimming fixes trailing spaces. COUNTIF also reads
*and?as wildcards (Google’s COUNTIF help). - #N/A “No matches are found in FILTER evaluation”. There are no duplicates. Wrap the formula in
IFERROR(…, "No duplicates"). - #REF! from UNIQUE or FILTER. The result needs to spill into cells that aren’t empty. Clear them or move the formula.
FAQ
Why does my duplicate highlight color empty cells?
Because an empty cell matches other empty cells. With a rule like =COUNTIF($A$2:$A, A2)>1, every blank cell in the range finds the other blanks, so the count is above 1 and the cell is colored, including all the unused rows below your data. Add a check that the cell isn’t empty: =AND(A2<>"", COUNTIF($A$2:$A, A2)>1).
How do I highlight duplicates in Google Sheets but ignore blanks?
Select the column without the header (for example A2:A), choose Format › Conditional formatting, choose Custom formula is and enter =AND(A2<>"", COUNTIF($A$2:$A, A2)>1). To color the whole row, select A2:C and use =AND($A2<>"", COUNTIF($A$2:$A, $A2)>1). If some “empty” cells contain spaces, use LEN(TRIM(A2))>0 instead of A2<>"".
How do I stop UNIQUE from returning a blank row?
Remove the blanks before UNIQUE sees them: =UNIQUE(TOCOL(A2:A, 1)), where the 1 tells TOCOL to skip empty cells, or =UNIQUE(FILTER(A2:A, A2:A<>"")). An open range like A2:A always contains empty rows, so =UNIQUE(A2:A) returns one empty entry.
Does Remove duplicates treat blank cells as duplicates?
A blank cell in a column you tick is compared like any other value, so if you tick only an Email column, every row with no email after the first one is removed, even though those rows are different people. Add a helper column that gives each blank row its own value, such as =IF(LEN(TRIM(A2))>0, A2, "blank row "&ROW()), paste it as values, and tick only that column in Data › Data cleanup › Remove duplicates.
Why do some empty-looking cells still count?
They aren’t empty. A cell with a space passes A2<>"", so two such cells match each other. Run Data › Data cleanup › Trim whitespace, or test LEN(TRIM(A2))>0 instead. A formula that returns "" is the opposite case: A2<>"" treats it as empty, but ISBLANK(A2) returns FALSE because the cell holds a formula, so prefer A2<>"" over ISBLANK.
How do I count duplicates without counting blanks?
To count the rows whose value appears more than once, use =SUMPRODUCT((A2:A<>"")*(COUNTIF(A2:A, A2:A)>1)). To count only the extra copies (the rows Remove duplicates would delete), use =ARRAYFORMULA(ROWS(TOCOL(A2:A, 1)) - ROWS(UNIQUE(LOWER(TOCOL(A2:A, 1))))). Both skip empty cells.
Install free from Google Workspace MarketplaceSee SheetDupes
Want to test it first? Try it on sample data (makes a copy of a 12-row example sheet in your Drive).
Related guides
- How to Find and Remove Duplicates in Google Sheets: Highlight, Count, Delete and Keep the Original (2026)
- How to Highlight Duplicates in Google Sheets: Conditional Formatting Formulas for One Column, Whole Rows, Repeats Only and Two Sheets (2026)
- How to Compare Two Columns or Two Sheets in Google Sheets to Find Matches and Duplicates (2026)
- Duplicates That Don’t Match Exactly in Google Sheets: Case, Extra Spaces, Gmail Dots, Phone Formats and Typos (2026)
- How to Remove Duplicates in Google Sheets but Keep the Latest, First or Highest Row per Key (2026)
- How to Prevent Duplicate Entries in Google Sheets: Data Validation Rules, Warnings and a Small Script (2026)
- How to Count Duplicates in Google Sheets: per Value, Extra Rows, Unique Counts and Why the Numbers Disagree (2026)
- How to Combine Two Lists or Several Tabs in Google Sheets Without Duplicates: VSTACK, UNIQUE, One Row per Key and Other Files (2026)
- How to Merge Duplicate Rows in Google Sheets: Sum the Numbers, Join the Notes and Fill the Blanks (2026)
- UNIQUE vs Remove Duplicates in Google Sheets: Live or Static, Letter Case, Spaces, Columns and Headers (2026)
- How to Remove Duplicates Within a Cell in Google Sheets: Comma-Separated Lists, Tags, Line Breaks and Letter Case (2026)
- How to Show Only the Duplicates in Google Sheets: Filter Duplicate Rows, List Repeated Values and Find Rows That Appear Once (2026)
- How to Find Duplicates Across Multiple Columns in Google Sheets: Rows That Match on Two or More Columns, and Values Repeated Anywhere in a Range (2026)
- How to Remove Duplicates Automatically in Google Sheets: Apps Script on a Daily Timer, on Form Submit or From a Menu (2026)
- How to Find Duplicate Transactions in Google Sheets: Double-Imported Rows, Invoices Paid Twice and Same-Amount Charges Within a Few Days (2026)
- How to Format Phone Numbers in Google Sheets: Strip Dashes and Spaces, Show (555) 010-1234, Handle +1 and Extensions, Then Find Duplicate Contacts (2026)
- How to Change Text Case in Google Sheets: UPPERCASE, lowercase, Proper Case Names, Sentence Case and Duplicates That Differ Only in Case (2026)