# How to highlight duplicates in Google Sheets

URL: https://goingstellar.ro/reference/sheets/recipes/highlight-duplicates/

Add a conditional formatting rule with the custom formula =COUNTIF(range, first_cell)>1 and every value that appears more than once gets the color. The range stays fixed while the first cell moves down with each row. The same formula in a helper column returns TRUE or FALSE per row, a quick way to test the rule.

## Steps

1. Keep the values in one column, for example A2:A7, with a header in row 1.
2. Select A2:A7, then open Format → Conditional formatting.
3. Under the rule type, choose Custom formula is.
4. Enter the formula from the first example. The COUNTIF range is locked with dollar signs, and the criterion is the first selected cell, A2.
5. Choose the fill color and apply the rule. Every value whose count is above 1 gets colored, the first copy included.
6. To leave the first copy alone, grow the range as in the third example: only its start is locked.
7. For a match that respects uppercase and lowercase, use the EXACT version from the fourth example.

## Examples

The examples use this table, starting in A1:

| Email |
|---|
| ana@x.ro |
| dan@x.ro |
| ANA@x.ro |
| ion@x.ro |
| dan@x.ro |
| ana@x.ro  |

```
=COUNTIF($A$2:$A$7, A2)>1
```

Result: `TRUE`

The rule itself, written for the first cell A2. TRUE means the value appears more than once in the list. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=ARRAYFORMULA(COUNTIF(A2:A7, A2:A7)>1)
```

Result: 

| TRUE |
|---|
| TRUE |
| TRUE |
| FALSE |
| TRUE |
| FALSE |

The same test for the whole column in one cell: one TRUE or FALSE per row, handy for checking before you color anything. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=COUNTIF($A$2:A6, A6)>1
```

Result: `TRUE`

Only the repeats. The range grows from A2 down to the current row, so the first copy counts as 1 and stays unmarked. Here it is the second dan@x.ro. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SUMPRODUCT(EXACT($A$2:$A$7, A4)*1)>1
```

Result: `FALSE`

Case-sensitive version for ANA@x.ro. EXACT sees ana@x.ro and ANA@x.ro as different, so the result is FALSE. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=ARRAYFORMULA(COUNTIF(A2:A7, TRIM(A2:A7))>1)
```

Result: 

| TRUE |
|---|
| TRUE |
| TRUE |
| FALSE |
| TRUE |
| TRUE |

TRIM on the criterion turns the last criterion into ana@x.ro, which the column holds twice, so the last row now shows TRUE. The range is not trimmed, and the other rows stay as in the second example. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- COUNTIF ignores case, so ana@x.ro and ANA@x.ro are flagged as duplicates. Use SUMPRODUCT with EXACT when the case matters.
- A space at the end makes a different value: "ana@x.ro " is not flagged against ana@x.ro. Clean the data with TRIM, or put TRIM around the criterion in a helper column as in the last example.
- A fixed range gives TRUE for every copy, the first one too. The growing range from the third example gives TRUE only for the later copies.
- In a RO-locale file, the rule must use ";" between arguments. The same rule typed with a comma is rejected as an invalid formula.

## Compared with Excel

Same method in Excel: Conditional Formatting → New Rule → Use a formula, with the same COUNTIF rule. Excel also has a built-in Duplicate Values rule.

## Functions used

- [COUNTIF](https://goingstellar.ro/reference/sheets/countif/)
- [SUMPRODUCT](https://goingstellar.ro/reference/sheets/sumproduct/)
- [EXACT](https://goingstellar.ro/reference/sheets/exact/)
- [TRIM](https://goingstellar.ro/reference/sheets/trim/)
- [ARRAYFORMULA](https://goingstellar.ro/reference/sheets/arrayformula/)

## Sources

- [COUNTIF (Docs Editors Help)](https://support.google.com/docs/answer/3093480)
- [SUMPRODUCT (Docs Editors Help)](https://support.google.com/docs/answer/3094294)
- [EXACT (Docs Editors Help)](https://support.google.com/docs/answer/3094073)

