How to prevent duplicates in a column in Excel

Today I'll tell you how to prevent duplicates from appearing in a column of your Excel worksheet. This tip works in Microsoft Excel 365, 2021, 2019, 2016, and lower.

We covered a similar topic in one of our previous articles. So you should know how to automatically highlight duplicates in Excel once something has been typed.

This article will help you stop duplicates appearing in one or several columns in your Excel worksheet. So you can have only unique data in the 1st column of your table be there invoice numbers, stock keeping units, or dates, each mentioned only once.

How to stop duplication - 5 easy steps

Excel has Data Validation - one unfairly forgotten tool. With its help you can avoid errors occurring in your records. We will be sure to devote some future articles to this helpful feature. And now, as a warm-up, you will see a simple example of using this option. :)

Suppose, you have a worksheet named "Customers" that includes such columns as Names, Phone numbers, and Emails you use for sending newsletters. Thus all email addresses must be unique. Follow the steps below to avoid sending the same message to one client twice. Table withous duplicates. All email addresses must be unique

  1. If necessary, find and delete all duplicates from the table. You can first highlight the dupes and delete them manually after looking through the values. Or you can remove all duplicates with the help of the Duplicate Remover add-in.
  2. Select the entire column where you need to avoid duplicates. Click on the first cell with data keeping the Shift keyboard button pressed and then select the last cell. Or simply use the combination of Ctrl + Shift + End. It is important to select the 1st data cell first.  Select the entire column where you need to avoid duplicates

    Note: If your data are in a simple Excel range as opposed to a full-fledged Excel table, you need to select all the cells in your column, even the blank ones, from D2 to D1048576  Select all the cells in your column

  3. Go to Excel "Data" tab and click on the Data Validation icon to open the dialog box. Go to Excel 'Data' tab and click on the Data Validation icon to open the dialog box
  4. On the Settings tab, choose "Custom" from the Allow drop down list and enter =COUNTIF($D:$D,D2)=1 into the Formula box. Formula to count duplicate entries in a column

    Here $D:$D are the addresses of the first and the last cells in your column. Please pay attention to the dollar signs that are used to indicate absolute reference. D2 is the address of the first selected cell, it is not an absolute reference.

    With the help of this formula Excel counts the number of occurrences of the D2 value in the range D1:D1048576. If it is mentioned just once, then everything is fine. When the same value appears several times, Excel will show an alert message with the text you specify on the "Error alert" tab.

    Tip: You can compare your column with another column to find duplicates. The second column can be on a different worksheet or event workbook. For example, you can compare the current column with the one that contains the blacklisted emails of customers
    you don't won't to work with any longer. :) I will give more details about this Data Validation option in one of my future posts.

  5. Switch to the "Error alert" tab, and enter your text into the fields Title and Error message. Excel will show you this text as soon as you try to enter a duplicate entry into the column. Try to type the details that will be accurate and clear for you or your colleagues. Otherwise, in a month or so you can forget what it means.

    For example:
    Title: "Duplicate email entry"
    Message: "You have entered an email address that already exists in this column. Only unique emails are allowed." Only unique emails are allowed.

  6. Click OK to close the "Data validation" dialog.

    Now when you try to paste an address that already exists in the column, you will see an error message with your text. The rule will work both if you enter a new address into an empty cell for a new customer and if you try to replace an email for the existing client: Duplicate entry error

If your "No duplicates allowed" rule can have exceptions :)

On the fourth step choose Warning or Information from the Style menu list. The alert message behavior will change correspondingly:

Warning: The buttons on the dialog will turn as Yes / No / Cancel. If you click Yes, the value you enter will be added. Press No or Cancel to get back to editing the cell. No is the default button. Data validation: Warning style

Information: The buttons on the alert message will be Ok and Cancel. If you click Ok (the default one), a duplicate will be added. Cancel will take you back to the editing mode. Information about new duplicate entry

Note: I'd like to pay your attention again to the fact that the alert about a duplicate entry will appear only when you try to enter a value into a cell. Excel will not find existing duplicates when you configure the Data Validation tool. It will not happen even if there are more than 150 dupes in your column. :).

136 comments

  1. Hi,
    I am creating a time sheet for my team to use and I have three columns that I want to prevent people from entering the same data in the columns are time off/holiday leave, alternate work schedule day and comp time used. If somebody puts 8.25 in the alternate work schedule column I don’t want them to be able to put anything in the other two columns for that same day. And if somebody puts 8.25 in the time off column I don’t want anyone to be able to put that same value in either of the other columns for that same day. I hope that makes sense so far the formulas I’ve tried I haven’t worked. Is there a way to do this? Thank you so much

    • Hello!
      If I understand the problem correctly use the data validation tool with these formulas

      =((A1<>B1)*(A1<>C1)*(B1<>C1))+(COUNTBLANK(A1:C1)>1)

      or

      =(COUNTIF(A1:C1,A1)+COUNTIF(A1:C1,B1)+COUNTIF(A1:C1,C1))<4

  2. Will this duplicate rule only work when we enter a duplicate value or will it work with copy-paste also? (pasting the field value from other sourse)

  3. Why values keep on duplicates even not match . refer below numbers
    511010002201816129
    511010002201816128

    • Hi!
      The information you provided is not enough to understand your case and give you any advice, sorry.
      What formula do you use to identify duplicates?

      • just mentioned on angelie issues, it's same as my issue. this formula not work when user input long number such as 18-20 digit.
        Can you advise how to deal with it. Actually this number is different 511010002201816129-511010002201816128 but excel not allow as it is duplicate.

  4. I need to avoid a room reservation in a day if already book for a specific time (9:00am to 10:00am) of Room#1. plz suggest

  5. =COUNTIF($D:$D;D2)=1 should read as =COUNTIF($D:$D;D1)=1 for it to work properly

  6. Prevent duplicate is not working for copy paste data.

  7. Hi, i want to make a list of employees using data validation- list command. How I can restrict duplication in a single day.

  8. it's working well while typing but it doesn't work when I copy & paste the same value, shows no error, and paste the same value.
    can you sort our, please.

    thankks

  9. The column I wish to eliminate the entry of duplicates is populated by alphanumeric characters. The formula =COUNTIF($A$1:$A$20,A1)=1 does NOT work:

    - direct data entry (typing) meets automatic error message
    - copy date entry is permitted even if the same date already in the column.

    Excel 2016 - So what IS the correct, working method to prohibit duplicate entries?

    • Hello Rottweiller!
      Unfortunately, Data Validation does not always work (it is mentioned in the last paragraph of the article).
      It works only when you put information directly into a cell and press Enter to record changes at the end. If you replace data in a cell by copying or pasting another cell, Data Validation does not see those changes and cannot ban them.
      I recommend using Conditional Formatting to see such duplicates.
      You can use this formula as a condition: =COUNTIF($A$1:$A$20,A1)>1.
      Alternatively, simply use standard Highlight Cell Rules -> Duplicate Values

      • iam try but not working , any value enter coming error msg

  10. If I am copying the same data from another sheet to this column which I have validated,then this is not working out and does not throw any error.please help me in this

    • Hello Himanshi!
      Please describe your problem in more detail.
      How were you checking the column?
      What data are you trying to copy and paste?
      Does the size of the copy area coincide with the size of the paste area?
      How is it connected with looking for duplicates?
      If you give more information, I will try to help you.

  11. i have excel sheet with contact number this should be duplicate which was repeating again and again

  12. Strange, everything seems fine. but no dialog box pop u if duplicate value entered.

  13. Thank you alexander

  14. YOUR FORMULA SO GOOD AND WORKING, GET CONNECT WITH YOU

    THANK YOU SO MUCH

  15. THANK YOU, IT IS GREAT.

  16. Hi,

    It is not applicable when pasting. why that is so?

    thx

  17. This worked for me, thanks! One question: When the alert shows up, is there a way to track which cell the duplicate is in? Sometimes we have so many entries that manually looking for it can take a while. Thank you!

  18. CORRECTION

    Hi There,
    Minor issue detected.

    For Excel 2013 the formula as mentioned in the article is not allowed.
    The seperator between the range and the criteria must be a semicolon, instead of a comma, like this :

    =COUNTIF($D:$D;D2)=1

    Making this minor correction made it finally work for me ;-)

    Thanks

  19. Hi There,
    Minor issue detected.

    For Word/Office 2013 the formula as mentioned in the article is not allowed.
    The seperator between the range and the criteria must be a semicolon, instead of a comma, like this :

    =COUNTIF($D:$D;D2)=1

    Making this minor correction made it finally work for me ;-)

    Thanks

  20. i want to extract the report where mobile number and DATE are same so dont consider duplicate. only consider duplicate mobile numbers which have different date.

    Date Mobile
    9/18/17 4:09 PM 923005254870
    9/18/17 6:45 PM 923005254870
    9/14/17 6:10 PM 923008435348
    9/14/17 6:29 PM 923008435348
    9/7/17 8:13 PM 923023689646
    9/14/17 6:55 PM 923023689646
    9/9/17 1:00 PM 923032819439
    9/12/17 2:28 PM 923032819439

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)