Excel Formula to Return Duplicates: Step-by-Step Guide
In this article
To return or identify duplicates in Excel, the most efficient method is using the COUNTIF function. By entering =COUNTIF(A:A, A2)>1, Excel will return TRUE for any value that appears more than once in the specified range. This allows you to flag, filter, or extract repeated data points across your spreadsheet for cleaning or analysis.
What You'll Need
- A computer with Microsoft Excel installed (works on Office 365, 2021, 2019, and older versions).
- A dataset containing the information you wish to check for duplicates (e.g., a list of email addresses, product IDs, or customer names).
- An empty column adjacent to your data to house the formula results.
Step-by-Step
- Prepare Your Data: Ensure your data is organized in a clean column. For this example, assume your data is in Column A, starting from cell A2, with a header in A1.
- Create a Helper Column: Click on the cell immediately to the right of your first data entry (Cell B2). Label the header of this column "Duplicate Check" or "Is Duplicate?" to keep your sheet organized.
- Enter the COUNTIF Formula: In cell B2, type the following formula:
=COUNTIF($A$2:$A$100, A2). Replace$A$2:$A$100with the actual range of your data. The dollar signs are critical; they create an absolute reference, ensuring that as you drag the formula down, Excel always checks the same range of cells rather than shifting the search area downward. - Convert to a Boolean (True/False) Result: To make the result a simple "Yes" or "No" rather than a number, modify the formula to:
=COUNTIF($A$2:$A$100, A2)>1. Now, if a value appears twice or more, Excel will display "TRUE". If it appears only once, it will display "FALSE". - Apply the Formula to the Entire List: Hover your mouse over the bottom-right corner of cell B2 until the cursor turns into a small black cross (the Fill Handle). Double-click the cross or click and drag it down to the bottom of your dataset. Every row will now be evaluated.
- Filter for Duplicates: To see only the duplicate entries, select your header row, go to the Data tab, and click Filter. Click the dropdown arrow in the "Duplicate Check" column and uncheck "FALSE". This hides all unique entries, leaving only the duplicates visible on your screen.
- Extracting Duplicates to a New List (Advanced): If you are using Excel 365 or Excel 2021, you can use the UNIQUE function combined with FILTER to create a separate list of only the duplicates. Use the formula:
=UNIQUE(FILTER(A2:A100, COUNTIF(A2:A100, A2:A100)>1)). This will automatically spill a list of every value that had a duplicate, without showing the same duplicate multiple times.
Common Mistakes
One of the most frequent errors is forgetting the absolute references (the dollar signs) in the range part of the formula. If you use =COUNTIF(A2:A100, A2) and drag it down, the second row becomes =COUNTIF(A3:A101, A3). This means Excel stops looking at the top of your list as it moves down, which leads to "false negatives" where duplicates are missed because they occurred above the current search window.
Another common mistake is ignoring trailing or leading spaces. Excel treats "Apple" and "Apple " (with a space at the end) as two entirely different values. If your formula says FALSE but you can clearly see the words are the same, it is almost always due to invisible whitespace. You can fix this by wrapping your reference in the TRIM function: =COUNTIF($A$2:$A$100, TRIM(A2)).
Users also often confuse the "Remove Duplicates" tool with a formula. The Remove Duplicates tool (found in the Data tab) is destructive; it deletes the data permanently. Using a formula is a non-destructive method that allows you to review the duplicates before deciding which ones to delete or keep.
Tips
To make duplicates visually pop, use Conditional Formatting instead of a helper column. Select your data range, go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values.... This will instantly shade all duplicates in red, which is often faster than writing a formula if you only need to spot them rather than extract them.
If you are working with massive datasets (tens of thousands of rows), COUNTIF can slow down your workbook because it recalculates every time you make a change. In these cases, it is more efficient to sort your data alphabetically first. Once sorted, you can use a simple comparison formula in cell B3: =A3=A2. This only compares the current cell to the one directly above it, which is computationally much lighter than scanning the entire column.
For those who need to identify the first instance of a value as unique and only mark the subsequent occurrences as duplicates, use a growing range. Instead of $A$2:$A$100, use $A$2:A2. The formula =COUNTIF($A$2:A2, A2)>1 will return FALSE for the first time it sees a value and TRUE for every time that value appears again later in the list.
Troubleshooting
If your formula is returning "FALSE" for values that you know are duplicates, first check for formatting inconsistencies. Ensure that all cells are formatted as "General" or "Text". If some numbers are stored as text and others as actual numbers, Excel will not recognize them as duplicates. You can standardize this by selecting the column, going to the Data tab, selecting Text to Columns, and clicking Finish immediately.
If you see a #NAME? error, it usually means there is a typo in the function name (e.g., writing "COUNTIFS" when you meant "COUNTIF" or misspelling the word entirely). Double-check the spelling and ensure you have closed all parentheses.
If the formula is returning a number (like 2 or 3) instead of TRUE/FALSE, you likely omitted the >1 part of the formula. The COUNTIF function by itself simply counts occurrences; adding the "greater than 1" logic is what converts that count into a duplicate flag.
If the results are not updating when you change a value in the data column, check your Calculation Options. Go to the Formulas tab, click Calculation Options, and ensure Automatic is selected. If it is set to Manual, you will have to press F9 to refresh the duplicate checks.
Frequently Asked Questions
Can I find duplicates across two different columns?
Yes. To check if a value in Column A also exists in Column B, use =COUNTIF(B:B, A2)>0. This tells you if the specific item in A2 appears anywhere in the entirety of Column B.
How do I return only the unique values and hide duplicates?
The easiest way is to use the =UNIQUE(A2:A100) formula in a new cell. This creates a dynamic list containing one instance of every item found in the original range, effectively stripping away all duplicates.
Does this formula work for case-sensitive duplicates?
No, COUNTIF is not case-sensitive; it treats "APPLE" and "apple" as the same. To find case-sensitive duplicates, you must use a combination of SUMPRODUCT and EXACT: =SUMPRODUCT(--EXACT($A$2:$A$100, A2))>1.
Can I use this formula to find duplicates in multiple columns at once (like First and Last Name)?
Yes, use the COUNTIFS function (with an 'S'). For example: =COUNTIFS($A$2:$A$100, A2, $B$2:$B$100, B2)>1. This will only return TRUE if both the first name and last name match another row.
Is there a limit to how many rows the formula can check?
While Excel supports over a million rows, using complex array formulas or COUNTIF on very large ranges can cause significant lag. For datasets exceeding 100,000 rows, consider using the Power Query tool (Data > Get Data) to remove or group duplicates.