Find Duplicates Formula
COUNTIF counts how many times a value appears in a list. If the count is above one, the value is a duplicate. A small change to the range lets you flag only the repeats and keep the first occurrence clean.
Free, no sign-up required · 5 free generations a day
Last updated
Describe your task, get the formula
Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.
Duplicate-finding formulas
=COUNTIF($A$2:$A$100, A2) > 1
=COUNTIF($A$2:A2, A2) > 1
=COUNTIFS($A$2:$A$100, A2, $B$2:$B$100, B2) > 1The first formula marks every copy of a repeated value. The second uses an expanding range so only the second and later copies are flagged. COUNTIFS compares several columns at once, which finds duplicate rows rather than duplicate cells.
Examples
Label every duplicate
=IF(COUNTIF($A$2:$A$100,A2)>1,"Duplicate","")Shows Duplicate next to every cell whose value appears more than once in the list, including the first copy.
Flag only the repeat occurrences
=IF(COUNTIF($A$2:A2,A2)>1,"Duplicate","")Because the range ends at the current row, the first copy counts as 1 and stays unmarked. Filter on Duplicate and delete those rows to keep one copy of each value.
Check whether a value exists in another list
=IF(COUNTIF(Sheet2!$A:$A,A2)>0,"In both","Only here")Counts matches in column A of Sheet2. A result above zero means the value from this sheet also appears there.
Common mistakes and how to fix them
Long numbers are wrongly reported as duplicates
COUNTIF only compares the first 15 digits of a number, so card numbers and long IDs can match falsely. Store them as text and use SUMPRODUCT(--(range=A2)) instead.
Values that look identical are not flagged
A trailing space, or a number stored as text in one list and as a real number in the other, breaks the match. COUNTIF ignores letter case but not extra spaces, so clean the data with TRIM first.
Wrong counts for text containing * or ?
COUNTIF treats * and ? as wildcards. To match them literally, put a ~ in front of the character in the criteria.
Frequently asked questions
Can I highlight duplicates instead of labeling them?
Yes. Use conditional formatting with the formula =COUNTIF($A$2:$A$100,A2)>1 as the rule, and pick a fill color.
How do I get a list without duplicates?
In Excel 2021, Microsoft 365, and Google Sheets use =UNIQUE(A2:A100). In older Excel use the Remove Duplicates tool on the Data tab.
Does it work in Google Sheets?
Yes. COUNTIF and COUNTIFS use the same syntax in Excel and Google Sheets.
Don't want to write it by hand?
Describe what you need in plain English and get a ready-to-use formula in seconds.
Try the formula generator