Select the column, open Format > Conditional formatting, choose Custom formula is under “Format cells if” and enter =COUNTIF($A$2:$A$100,A2)>1 (changed to match your range), then pick a fill color and click Done. To color only the second and later copies, or the whole row, swap in one of the variations below; the rules work in Sheets on a computer and in the Android app (Google documents the Data cleanup tools below for computers only).
What you need before you start
You need edit access to the spreadsheet. A view-only or comment-only file lets you look at existing colors but not add rules, so ask the owner for edit access or make a copy with File > Make a copy.
Where you work matters too. Google documents conditional formatting for Sheets in a web browser and in the Android app. On an iPhone or iPad, Google says you can see conditional formatting rules but not edit them, so create the rule on a computer or an Android device and it will show up on your iPhone or iPad afterward.
Two terms come up in every formula on this page:
- Apply to range is the block of cells the rule colors, for example A2:A100. It is filled in from whatever you selected, and you can edit it in the sidebar.
- Absolute and relative references. A dollar sign locks a column or row. In
$A$2:$A$100the range never moves, so every cell is compared with the same list. The plainA2has no dollar signs, so Sheets shifts it to A3, A4 and so on as it checks each cell. Google’s help page describes this same use of $ signs in custom formulas.
Highlight every duplicate in one column
This example uses a small, made-up sign-up list. Column A holds names, column B holds teams, and row 1 holds the headers.
| Row | A: Name | B: Team |
|---|---|---|
| 2 | Alex | Sales |
| 3 | Jordan | Sales |
| 4 | Priya | Ops |
| 5 | alex | Sales |
| 6 | Sam | Ops |
| 7 | Jordan (followed by a hidden trailing space) | Sales |
| 8 | Priya | HR |
- Select the cells to check, starting below the header. Here that is A2:A8. Leaving the header out stops a name that matches the column label from being flagged.
- Click Format in the menu bar, then Conditional formatting. A sidebar opens on the right. If the cells already have a rule, use the option below the existing rules to add a new one (Google’s help page calls it Add new rule) so you don’t overwrite the old rule.
- Stay on the Single color tab and check that Apply to range shows A2:A8.
- Under Format cells if, open the drop-down and choose Custom formula is (near the bottom of the list).
- In the Value or formula box, type
=COUNTIF($A$2:$A$8,A2)>1. The first cell in the formula (A2) must be the top-left cell of Apply to range, or every highlight will be shifted by a row. - Under Formatting style, pick a fill color, bold text or a text color.
- Click Done.
What to expect: Sheets colors A2, A4, A5 and A8. COUNTIF isn’t case sensitive (Google states this on its COUNTIF page), so “Alex” and “alex” count as the same value. Jordan is not colored, because the trailing space in A7 makes the two entries different text. The fix for that is under the troubleshooting heading below.
The rule stays live. Type a name that already exists and it changes color as soon as you press Enter; fix a typo and the color disappears. Nothing in your data changes, only how it looks.
If you want the rule to cover a growing list, use a bigger range such as $A$2:$A$1000 in both the formula and Apply to range, or a whole column with =COUNTIF($A:$A,A1)>1 applied to A1:A (which also checks the header row).
Color only the second and later copies
Coloring every copy makes it hard to tell which entry to keep. To leave the first one plain and flag only the repeats, use a range that grows as Sheets moves down the column:
=COUNTIF($A$2:A2,A2)>1
The start of the range is locked ($A$2) but the end (A2) is relative, so for row 5 Sheets counts only A2:A5, and for row 8 only A2:A8. In the sample list this colors A5 (alex) and A8 (the second Priya), and leaves the first Alex and the first Priya alone. If you accidentally write $A$2:$A$2, the range never grows and nothing is colored.
Highlight the whole row
To shade the entire record when a name repeats, select A2:B8 (all the columns you want colored) and use:
=COUNTIF($A$2:$A$8,$A2)>1
The extra dollar sign in $A2 locks the check to column A. Without it, the cells in column B would compare their own team names instead of the name in column A. In the sample, rows 2, 4, 5 and 8 are shaded across both columns.
Match on two columns, several columns or another sheet
A repeat only when two columns match
Sometimes a name can repeat legitimately (two people called Priya on different teams) and you only want rows where the name and the team both match. COUNTIFS takes pairs of ranges and criteria:
=COUNTIFS($A$2:$A$8,$A2,$B$2:$B$8,$B2)>1
Apply it to A2:B8. In the sample only rows 2 and 5 are colored (Alex and alex, both in Sales); the two Priyas are on different teams, so they stay plain. Google notes that each extra range in COUNTIFS must have the same number of rows and columns as the first one, so keep both ranges the same size.
A value repeated anywhere in a block of columns
To flag any value that appears more than once anywhere in a grid, say A2:C50, lock the full block and apply the rule to the same block: =COUNTIF($A$2:$C$50,A2)>1. Here A2 stays fully relative so each cell checks its own value.
Values that also appear on another sheet
Google’s conditional formatting page says custom formulas can only reference the same sheet with normal notation, and that you need the INDIRECT function to reference another sheet. To color names in column A that already appear in A2:A100 of a tab called Signups, use:
=COUNTIF(INDIRECT("Signups!A2:A100"),A2)>0
The test is >0 here because you want any match at all on the other tab. INDIRECT reads the sheet name as plain text, so if you rename the tab, edit the formula to match. Comparing two separate spreadsheet files is a different job that needs the data brought into one file first.
Upper and lower case, spaces and blank cells
Because COUNTIF ignores case, “PRIYA” and “priya” count as duplicates. If case matters (product codes, for example), use EXACT, which Google describes as testing whether two strings are identical, inside SUMPRODUCT:
=SUMPRODUCT(--EXACT($A$2:$A$8,A2))>1
On the sample list this colors only A4 and A8, because Alex and alex no longer match. EXACT also avoids a COUNTIF quirk: Google treats ? and * in the criterion as wildcards, so a code such as AB* would count every entry that starts with AB.
Extra spaces are the most common reason a visible duplicate is not colored. A formula such as =COUNTIF($A$2:$A$8,TRIM(A2))>1 does not fix it: TRIM cleans only the cell being checked, while the copy with the stray space in the range still fails to match. Clean the data itself instead. Select the column and click Data > Data cleanup > Trim whitespace; Google notes that non-breaking spaces are not trimmed. After that, the two Jordans in the sample are colored too.
If empty cells in your range get colored, add a blank check in front of the count: =AND(A2<>"",COUNTIF($A$2:$A$100,A2)>1).
Check, change or remove the rule
To confirm the rule is doing what you expect, sort a copy of the column or type a known duplicate at the bottom of the list and watch it change color. Then delete the test entry.
To edit the rule, select any cell it covers, open Format > Conditional formatting, click the rule, change the formula, range or color, and click Done. Google evaluates rules in the order listed and the first true rule sets the cell’s format, so drag your duplicate rule to the top if another rule’s color is winning.
To remove it, point to the rule in the sidebar and click Remove (the trash can icon). On Android, tap the Remove icon next to the rule and then tap Done. The colors go away and your data stays exactly as it was. For clearing every rule on a sheet at once, see the steps for removing conditional formatting in Google Sheets.
Delete the duplicates once you’ve reviewed them
Highlighting changes nothing, which is why it is the safer first step. When you are sure the repeats can go, select the range and use Data > Data cleanup > Remove duplicates, choose which columns to compare and whether the data has a header row, then click Remove duplicates. Google’s help page warns that cells with identical values but different letter cases, formatting or formulas are treated as duplicates, so “Alex” and “alex” would collapse into one row. Make a copy of the sheet first if you are unsure. More detail is in the walkthrough on removing duplicates in Google Sheets.
The same COUNTIF idea works for other color rules too, such as making a cell change color based on its value. If you’re working in Excel instead of Sheets, you can create a conditional formatting rule in Excel, which also has a built-in duplicate values option.
Formulas that highlight too much, too little or nothing
Why is every cell in the column colored?
Either the column has no unique values (team or region columns often repeat on purpose), or the cell being checked got dollar signs. In =COUNTIF($A$2:$A$100,$A$2)>1 every cell tests the value in A2, so if A2 repeats, the whole column is colored; keep the second argument plain (A2). The opposite mistake, a range without dollar signs such as A2:A100, makes the range slide down one row for each cell, so the last copy of each value is missed. Check that the range reads $A$2:$A$100.
Why are the highlights one row off?
The cell in the formula doesn’t match the first cell of Apply to range. If the range starts at A2, the formula must use A2; if it starts at A1, use A1.
Why did I get unique values instead of duplicates?
The formula ends in =1 instead of >1. A count of exactly 1 means a value appears once, which is a handy rule in its own right if you want to spot the one-off entries.
Why does the sidebar show extra copies of my rule?
Copying and pasting is the usual cause. Google notes that when you copy and paste cells that have formatting rules, the rules are applied to the pasted data, so a pasted block can end up with its own rule and its own small range that only compares cells inside that block. Delete the extra rules and widen Apply to range on the original one so every row is checked against the full list.
Can a big sheet slow down?
It can. Every cell in Apply to range runs its own count over the whole range, so a rule on tens of thousands of rows does a lot of work. Keep the range close to the size of your data rather than whole columns if the sheet starts to feel sluggish.
Next step: set up the basic rule on your own list, then use the “second and later copies” version when you are ready to decide which entries to delete. Google’s help page on conditional formatting rules in Google Sheets lists the other built-in conditions if you want to combine rules.
Matthew Simpson has been creating online tutorial for computers and smartphones since 2010. His work has been read millions of times and helped people to solve a number of various tech problems. His specialties include Windows, iPhones, and Google apps.