Find duplicates with COUNTIF
Spot invoice numbers, emails, or product codes that appear more than once, mark every repeat, and keep the first one.
BasicsBeginner7 minExcel · Google Sheets
Example content. The numbers are fictional and made for learning.
Goal
Find the invoice numbers that are listed twice.
Why this is useful
A duplicate invoice is paid twice, a duplicate customer gets two letters, and a duplicate order is counted twice in sales. COUNTIF finds them before they cost money.
Example
| Row | A | B |
|---|---|---|
| 1 | Invoice | Customer |
| 2 | INV-1001 | Harbor Goods |
| 3 | INV-1002 | Nord Design |
| 4 | INV-1003 | Harbor Goods |
| 5 | INV-1002 | Nord Design |
| 6 | INV-1005 | Lumen AB |
| 7 | INV-1006 | Lumen AB |
| 8 | Times INV-1002 appears | 2=COUNTIF($A$2:$A$7,A3) |
Steps
1. Count each value in the list
Next to the first value, type =COUNTIF($A$2:$A$7,A2). It counts how often that value appears in the whole list. Lock the list with $.
2. Copy it down
Every row now shows a count. 1 means unique; 2 or more means the value appears elsewhere too.
3. Turn it into a label
Wrap it in IF: =IF(COUNTIF($A$2:$A$7,A2)>1,"Duplicate",""). Filter the column on Duplicate to see them all.
4. Keep the first, flag the rest
Count only from the top down to the current row: =IF(COUNTIF($A$2:A2,A2)>1,"Repeat",""). The first copy stays clear; later copies are flagged.
5. Remove them when you are sure
Excel has Data, Remove Duplicates; Google Sheets has Data, Data clean-up, Remove duplicates. Make a copy of the sheet first.
Formulas by language
Cell names such as B2 stay the same. The function name and the character between arguments follow the spreadsheet language. The English line in each list is the reference form used on this site, not a universal spelling. When the decimal sign is a comma, arguments are usually separated with a semicolon, because the comma is already used in numbers.
How many times this row's value appears in the list.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=COUNTIF($A$2:$A$7,A2)Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=ANTAL.OM($A$2:$A$7;A2)German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=ZÄHLENWENN($A$2:$A$7;A2)French (France)
Decimals look like 1,5. Arguments are separated with ;.
=NB.SI($A$2:$A$7;A2)Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=CONTAR.SI($A$2:$A$7;A2)Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=CONTAR.SI($A$2:$A$7,A2)Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=CONT.SE($A$2:$A$7;A2)Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=CONTA.SE($A$2:$A$7;A2)Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=AANTAL.ALS($A$2:$A$7;A2)
Marks every copy, the first one included.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=IF(COUNTIF($A$2:$A$7,A2)>1,"Duplicate","")Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=OM(ANTAL.OM($A$2:$A$7;A2)>1;"Duplicate";"")German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=WENN(ZÄHLENWENN($A$2:$A$7;A2)>1;"Duplicate";"")French (France)
Decimals look like 1,5. Arguments are separated with ;.
=SI(NB.SI($A$2:$A$7;A2)>1;"Duplicate";"")Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=SI(CONTAR.SI($A$2:$A$7;A2)>1;"Duplicate";"")Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=SI(CONTAR.SI($A$2:$A$7,A2)>1,"Duplicate","")Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=SE(CONT.SE($A$2:$A$7;A2)>1;"Duplicate";"")Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=SE(CONTA.SE($A$2:$A$7;A2)>1;"Duplicate";"")Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=ALS(AANTAL.ALS($A$2:$A$7;A2)>1;"Duplicate";"")
Marks only the second and later copies.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=IF(COUNTIF($A$2:A2,A2)>1,"Repeat","")Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=OM(ANTAL.OM($A$2:A2;A2)>1;"Repeat";"")German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=WENN(ZÄHLENWENN($A$2:A2;A2)>1;"Repeat";"")French (France)
Decimals look like 1,5. Arguments are separated with ;.
=SI(NB.SI($A$2:A2;A2)>1;"Repeat";"")Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=SI(CONTAR.SI($A$2:A2;A2)>1;"Repeat";"")Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=SI(CONTAR.SI($A$2:A2,A2)>1,"Repeat","")Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=SE(CONT.SE($A$2:A2;A2)>1;"Repeat";"")Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=SE(CONTA.SE($A$2:A2;A2)>1;"Repeat";"")Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=ALS(AANTAL.ALS($A$2:A2;A2)>1;"Repeat";"")
The same spoken language can use different separators in different countries. Spanish in Spain often uses a comma for decimals and a semicolon between arguments. Spanish in Mexico often uses a period and a comma. If a formula is rejected, check the spreadsheet locale.
Excel and Google Sheets
- COUNTIF works the same in Excel and Google Sheets.
- COUNTIF ignores upper and lower case, so inv-1002 and INV-1002 count as the same. Extra spaces make values different: use TRIM to clean them.
- Conditional formatting can also colour duplicates: in Excel, Home, Conditional Formatting, Highlight Cells Rules, Duplicate Values.
- Function names and the separator between arguments follow the spreadsheet language. Excel uses the language of your installation; Google Sheets uses the spreadsheet locale under File, Settings.
- Workbooks from Hellosheetwise store formulas in English. Excel and Google Sheets show them in your language when you open the file.
If something goes wrong
Obvious duplicates show 1.
One value has an extra space or is a number stored as text. Clean the column, then count again.
The counts change when copied down.
The list range is not locked. Use $A$2:$A$7, not A2:A7.
COUNTIF is slow on a big sheet.
Point at the used rows, not whole columns, or remove duplicates once and stop counting.