ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. How to Count Duplicates in Excel

How to Count Duplicates in Excel

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To count duplicates in Excel, use COUNTIF. =COUNTIF($A$2:$A$8,A2) shows how many times the value in A2 appears; any result above 1 is a duplicate. To count every row that is part of a duplicate set in one cell, use =SUMPRODUCT(--(COUNTIF(A2:A8,A2:A8)>1)). Decide first whether you need repeated rows, extra copies or repeated values.

Key takeaways

  • "How many duplicates" can mean three things: rows involved, extra copies, or values that repeat.
  • =COUNTIF($A$2:$A$8,A2) gives how often each value appears; above 1 means a duplicate.
  • =SUMPRODUCT(--(COUNTIF(A2:A8,A2:A8)>1)) counts every row that belongs to a duplicate set.
  • Rows minus unique values gives the extra copies that Remove Duplicates would delete.
  • COUNTIF ignores capitals but not spaces, so clean the data with TRIM first.
On this page+
  1. Three ways to count duplicates
  2. Step 1: Count how often each value appears
  3. Step 2: Count all duplicate rows in one cell
  4. Step 3: Count extra copies (first occurrence not counted)
  5. How to count values that are repeated
  6. How to count duplicates across two columns
  7. Why COUNTIF misses some duplicates
  8. Practise it

To count duplicates in Excel, COUNTIF does nearly all the work: point it at the list and at one value, and it tells you how many times that value appears. The tricky part is deciding what "how many duplicates" means, because there are three common answers. This guide shows each one on the same short list, plus duplicates across two columns and the data problems that hide repeats.

Three ways to count duplicates#

Every example uses this customer list in A1:A8:

A
1Customer
2Ana
3Ben
4Cara
5Ana
6Dan
7Ben
8Ana

Ana appears 3 times, Ben twice, and Cara and Dan once each. Now, how many duplicates are there? It depends on the question:

QuestionAnswerWhy
How many rows are part of a duplicate set?5Ana's 3 rows and Ben's 2 rows
How many extra copies would be removed?3Two extra Anas and one extra Ben
How many values are repeated?2Ana and Ben

All three are correct. Pick the one your task actually asks for, then use the matching formula below. In a job test, read the question twice: "how many customers ordered more than once" is the repeated-values count (2), while "how many orders came from repeat customers" is the duplicate-rows count (5).

Step 1: Count how often each value appears#

A helper column with COUNTIF shows the count for every row. In B2, type:

Excel formula
=COUNTIF($A$2:$A$8,A2)

Fill it down to B8 (Windows: Ctrl+D; Mac: ⌘D). The results are 3, 2, 1, 3, 1, 2, 3. Each number is how many times that row's name appears in the whole list.

The $ signs lock the list so it stays A2:A8 on every row, while A2 changes to A3, A4 and so on. Without them, the range would shrink as you fill and the counts would be wrong. For more on how COUNTIF works, see how to use COUNTIF.

To turn the counts into labels, wrap them in IF:

Excel formula
=IF(COUNTIF($A$2:$A$8,A2)>1,"Duplicate","Unique")

Ana and Ben rows show Duplicate; Cara and Dan show Unique.

Step 2: Count all duplicate rows in one cell#

To get the total without a helper column, use SUMPRODUCT around COUNTIF:

Excel formula
=SUMPRODUCT(--(COUNTIF(A2:A8,A2:A8)>1))

Here is how it works. COUNTIF(A2:A8,A2:A8) uses the whole list as the criteria, so it returns one count per row: {3,2,1,3,1,2,3}. >1 turns each count into TRUE or FALSE. -- turns those into 1s and 0s, and SUMPRODUCT adds them. The result is 5.

If you have a helper column of counts already, =COUNTIF(B2:B8,">1") gives the same 5.

Step 3: Count extra copies (first occurrence not counted)#

The number of extra copies is the number of rows minus the number of unique values. These are the rows that Data > Remove Duplicates would delete:

Excel formula
=ROWS(A2:A8)-SUMPRODUCT(1/COUNTIF(A2:A8,A2:A8))

SUMPRODUCT(1/COUNTIF(A2:A8,A2:A8)) counts the unique values. Each of Ana's three rows adds 1/3, each of Ben's rows adds 1/2, and Cara and Dan add 1 each, so the total is 4. Seven rows minus 4 unique values gives 3. In Excel 2021 or Microsoft 365, =ROWS(A2:A8)-COUNTA(UNIQUE(A2:A8)) is easier to read and gives the same answer. Note that the 1/COUNTIF version fails with #DIV/0! if the range contains blank cells.

To flag only the second and later copies, use a range that grows as you fill down:

Excel formula
=COUNTIF($A$2:A2,A2)>1

Only the start of the range is locked, so on row 5 it checks A2:A5. The result is TRUE for row 5 (the second Ana), row 7 (the second Ben) and row 8 (the third Ana): three extra copies. The guide to counting unique values covers the unique side in more depth.

How to count values that are repeated#

To count how many different values appear more than once, divide each row's flag by its count, so each repeated value adds up to exactly 1:

Excel formula
=SUMPRODUCT((COUNTIF(A2:A8,A2:A8)>1)/COUNTIF(A2:A8,A2:A8))

Ana's three rows each add 1/3 and Ben's two rows each add 1/2. Cara and Dan add 0, because their flag is FALSE. The result is 2: Ana and Ben.

How to count duplicates across two columns#

Sometimes a row is only a duplicate when two values match together, such as the same customer on the same date. Say column B holds the order date. Use COUNTIFS with a pair for each column:

Excel formula
=COUNTIFS($A$2:$A$8,A2,$B$2:$B$8,B2)

A result above 1 means another row has the same name and the same date. A customer who ordered on two different dates is not a duplicate by this rule. Add more pairs for more columns.

Why COUNTIF misses some duplicates#

COUNTIF compares values exactly, apart from capitals. These differences hide duplicates:

  1. Extra spaces. "Ana " with a trailing space is a different value from "Ana". Clean the column with TRIM in a helper column first.
  2. Spelling and punctuation. "Ana Lopez" and "Ana López" are different to Excel.
  3. Long numbers. COUNTIF treats text that looks like a number as a number, and Excel keeps only 15 significant digits. Long IDs such as card or account numbers can then look like duplicates when they aren't.

COUNTIF is not case-sensitive, so "ana" and "ANA" count as the same name, which is usually what you want.

To see the duplicates rather than count them, use conditional formatting; see how to highlight duplicates. The same counting pattern also works for answers in a survey, as shown in how to count Yes, No and ticks.

Practise it#

COUNTIF with a locked range is the building block for every duplicate check. Practise COUNTIF in a live spreadsheet: you type the formula and the lesson checks it instantly. The COUNTIF function guide has the syntax on one page, and the exercise here lets you try the one-cell duplicate count.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

In C2, write one formula that counts how many rows in A2:A8 hold a name that appears more than once. Use SUMPRODUCT around COUNTIF(A2:A8,A2:A8)>1.

fx
ABCD
1
Customer
Order
2
Ana
1001
3
Ben
1002
4
Cara
1003
5
Ana
1004
6
Dan
1005
7
Ben
1006
8
Ana
1007
9
10
11

Tip: COUNTIF(A2:A8,A2:A8) gives a count for every row. Compare it with >1, turn TRUE and FALSE into 1 and 0 with --, and add them with SUMPRODUCT.

Practise this in a lesson

LessonCOUNTIFCount the cells that match a condition, from exact words to number checks like ">=8".Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and a live exercise.

Frequently asked questions

How do I count duplicates in Excel?

+

Add a helper column with =COUNTIF($A$2:$A$8,A2) and fill it down. Each row shows how many times its value appears in the list, and any number above 1 is a duplicate.

How do I count the total number of duplicate rows?

+

Use =SUMPRODUCT(--(COUNTIF(A2:A8,A2:A8)>1)). It counts every row whose value appears more than once, including the first copy.

How do I count duplicates without counting the first occurrence?

+

Subtract the number of unique values from the number of rows: =ROWS(A2:A8)-SUMPRODUCT(1/COUNTIF(A2:A8,A2:A8)). The result is the number of extra copies that Remove Duplicates would delete.

How do I count duplicates across two columns?

+

Use COUNTIFS with both columns: =COUNTIFS($A$2:$A$8,A2,$B$2:$B$8,B2). A row is a duplicate only when both its values appear together in another row.

Is COUNTIF case-sensitive when counting duplicates?

+

No. COUNTIF treats Ana and ANA as the same value. Extra spaces do matter, though, so Ana with a trailing space counts as a different value.

Sources

  • COUNTIF function - Microsoft Support
  • Find and remove duplicates - Microsoft Support
  • SUMPRODUCT function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Three ways to count duplicates
  2. Step 1: Count how often each value appears
  3. Step 2: Count all duplicate rows in one cell
  4. Step 3: Count extra copies (first occurrence not counted)
  5. How to count values that are repeated
  6. How to count duplicates across two columns
  7. Why COUNTIF misses some duplicates
  8. Practise it

Keep reading

Conditional math· 6 min read

How to Count Unique Values in Excel

In Excel 2021 and Microsoft 365, count unique values with =COUNTA(UNIQUE(B2:B11)): UNIQUE lists each different value once and COUNTA counts the list. Add a condition with FILTER, as in =COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="East"))). In older Excel, use =SUMPRODUCT(1/COUNTIF(B2:B11,B2:B11)) instead.

Conditional math· 6 min read

How to Count Cells With Text in Excel

To count cells that contain text in Excel, use COUNTIF with an asterisk: =COUNTIF(B2:B8,"*"). The * wildcard matches any text, so numbers, dates and blank cells are not counted. COUNTA is different: it counts every cell that isn't empty, numbers included. To count one specific word, put it in quotes: =COUNTIF(B2:B8,"Yes").

Conditional math· 6 min read

How to Count Yes, No and Ticks in Excel

To count Yes answers in Excel, use COUNTIF with the word in quotes: =COUNTIF(B2:B8,"Yes"). It counts yes, Yes and YES alike. Use "No" for No answers and "" for blanks. For checkboxes, which store TRUE or FALSE, use =COUNTIF(B2:B8,TRUE). For tick symbols, count the symbol itself, such as =COUNTIF(B2:B8,"✓").

More on conditional math

  • How to Use COUNTIF in Excel (With Criteria Examples)
  • COUNTIF Between Two Numbers in Excel
  • COUNTIF Contains Text: Count Partial Matches
  • COUNTIF With Dates: Before, After and Between
  • COUNTIF Greater Than, Less Than and Equal To
  • Count Non-Blank Cells With a Condition in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free