Sheetwise
Google Sheets · Written guide

Highlight Duplicate Emails in Google Sheets Without Deleting Rows

Color every repeated email without deleting any customer orders.

Download practice data · CSVStart the exercise

A published video is not available for this version yet. The complete written exercise and data are below.

Try it yourself

Import the CSV at D1, not A1. Apply conditional formatting to D2:E8 using the custom formula below. Four rows are highlighted. Change D5 to karel@example.com: only the two Noah rows remain highlighted. No orders are deleted.

=COUNTIF($D$2:$D$8,$D2)>1
Detailed steps
  1. 1. Select the rows to format

    We are working on the copy in columns D and E. Column D contains emails and column E contains order IDs. Select D two through E eight, leaving out the header.

  2. 2. Choose a custom formula

    Open Format, then Conditional formatting. Choose Custom formula is. This lets the color depend on whether the email on the current row appears more than once.

  3. 3. Count matches for each email

    Use COUNTIF with D two through D eight as the fixed comparison range. Add dollar signs to keep that range fixed. Compare it with dollar D two, and test whether the count is greater than one.

  4. 4. Choose the highlight color

    Choose a fill color and click Done. Both rows for Emma and both rows for Noah are highlighted. The other email addresses appear only once and stay uncolored.

  5. Repeated email does not mean bad data

    The dollar sign before D keeps the email column fixed while the row number changes. Repeated emails can be legitimate repeat customers, so review them instead of automatically deleting orders. Which field would you flag next: emails, order IDs, or product codes?

Highlight a relationship, not a bad order

Repeated email addresses can be legitimate repeat purchases. Conditional formatting keeps every order and calls attention to records sharing an address. The fixed email range searches the whole input, while the row-relative criterion changes for each formatted row. Applying the rule to both columns colors the complete order for easier review.

When the result looks wrong

The first row of the formatting range must align with the relative row in the formula. If the input starts in D2, use D2 in the criterion. Blank cells in a much larger range can be highlighted together; keep the example range bounded or add a nonblank condition for a growing sheet.

A check you can repeat

The initial example highlights four rows: both occurrences of each of two repeated addresses. Change D5 to karel@example.com; only the two occurrences of the other repeated address should remain colored. All seven orders remain present.

Preview the input data

EmailOrder
emma@example.comA101
noah@example.comA102
mia@example.comA103
emma@example.comA104
liam@example.comA105
noah@example.comA106
ava@example.comA107

Need help importing, choosing separators or setting the locale? How to use the practice files.

Official Google documentation

Continue with a related problem