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. :).

131 comments

  1. Manually entering duplicate values in this case seems to work, such as entering "123". When I input the data manually, it works fine. However, when I try to copy and paste the data, the cell accepts it, indicating that the data validation is not functioning properly in this scenario.

    • Hi! Unfortunately, validating data in Excel only works when typing. In your case, you need to use a VBA macro to check values when a cell changes.

      • Thanks Sir!

  2. Hi,

    I am going to make big Excel table and want to avoid duplicate addresses in it (Excel 2016).
    I have tried a solution with Data Validation and a formula posted here ( =COUNTIF($D:$D,D2)=1 ) but Excel does not accept it as a good formula.
    What should be done ?

    Regards,

    Kresimir

  3. Hi.

    I have several sheets in which I've used list data validation but it doesn't help stop duplicate entries... I need a particular data fetched from a previously checked list to avoid punching mistakes but it costs me duplicate entries. How can I stop duplicates while using allow list option in data validation, please help.

    • Hi! If I understand the question correctly, you are using a drop-down list to enter data. The drop-down list writes text values to the cell. To prevent duplicates, you can use the methods suggested in the article above. If this is not what you wanted, please explain the problem in more detail.

  4. Hey,

    I have a button which has a VBA Macro attached that imports data from a different sheet, and it seems like this bypasses the data validation. Do you have any tips on how to correct this?

    Thanks for the help.

  5. Eres lo máximo, millones de gracias!

  6. The instructions were clear, but doesn't seem to work for me...

    My range of names that I do not want duplicated are on sheet1, whereas the input cell is on sheet 2. (Feeds into another macro for naming the tabs) when I try to complete using the formula, the input cell will still accept any value. I've tried the formula on the input cell and the range but still cannot get it to work.

    Any advice please?

  7. First of all thanks for this great services you offer many end-users out there.

    Secondly, I have a question in relation to a searchable database in Excel where a Pivot Table is used, and a "Remove Duplicate" is ticked. Now assume that a business wants to keep records of the usage a vehicle whose registration number is N111-222W which was used by different staff members from 01 July 2023 to 30 July 2023. In the vehicle registration number the number N111-222W has to appear repeatedly by default, how can I record the usage history without duplicating the registration number?

    Regards,

    Reha

  8. Hi,
    Great tutorial! This is exactly what I needed.

    In my Sheet, F3:F202 is the range where the user would select an employee's name from a pulldown list. Each cell in the range already has a Data Validation Allow: List associated to it with Source Field: =EmpLst, a named range of employees names on another Sheet.

    How can I prevent a user from entering a duplicate name within the same range using =COUNTIF($F:$F,F3)=1 if I already have a Dropdown List?

    • Hi! Unfortunately, you cannot use two Data Validation rules in the same cell. To prohibit entering duplicates in a range, you can use VBA.

  9. Just an add-on to the well-described steps over here.

    I wanted to apply this technique to an excel file, that was stored on a remote terminal server.
    For some reason, I would always encounter an error while entering the formula in Data Validation ("Are you trying to enter a formula?")

    I copied the file onto my local PC and tried doing the same, and there were no more errors.

    It turns out, the system settings for the separators were different for the remote terminal server. So instead of:

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

    I used:

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

    Note the semi-colon instead of the comma separator.

    It took me a day to get around this. If somebody is also encountering the same issue, I hope this helps!

    Thanks, Ablebits, for the wonderful help!

    • This accepts the changes now, but it does not stop duplicates. What is the problem?

  10. i have 2columns, start dan end columns. i want to do
    1. end should larger than start
    2. customer need to enter start first then enter the end column.

    i try do below but not work well

    =AND(B2>A2,COUNTBLANK(A2)=0)

  11. Hi, I want to automatically move one column values to another column but only the unique values. for example: I have John 2 times in column A:A, now I want to automatically move John to column B:B but just as a unique value.
    I hope it does make scenes?

  12. 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

  13. 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)

  14. 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.

  15. 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

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

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

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

  19. 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

  20. 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

  21. 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.

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

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

  24. Thank you alexander

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

    THANK YOU SO MUCH

  26. THANK YOU, IT IS GREAT.

  27. Hi,

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

    thx

  28. 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!

  29. 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

  30. 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

  31. 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

  32. Hi,
    i have a list of data but all are 19 digits.
    Because of this, duplicates are not identified.
    Could you please share with us the solution.

    Thanks
    Anas

  33. Can this work across tabs? I am trying to prevent duplicate entries being used across 3 separate tabs, all saved in the single file. The cells are the same in each tab (ie. the same column) in each tab if this helps?

  34. Hello,

    It would seem that for this to work, you need to have a range with cells following one another. In my instance, my cells are individual, i.e. there could be 3 rows seperating them. This means that when i select the data for which i want the rule, it comes up as individual cells rather than a range.

    Any help is appreciated.

  35. thanks a lot for the explanation but i am a trainer and want to prepare a sheet that highlights the names of the trainees who got the training in past years, so that to avoid duplication in trainings

  36. how to validate name field in excel(cell should not accept number or special characters )?

  37. I have bulk entries in column $b1:$b450 , it also contains repeated text like "AAA" in cells B2, B5, B8, B10 so on.

    Now i want to give Sno in $A1:$A450, but i dont want that Serial number consider the duplicate text contain in other cells, it should treat 1 for all "AAA"

    Let me know the formula

    Thanks

  38. Hi, how do I avoid duplicate entries on multiple sheets. E.g I have listed invoices by month to month on a different worksheet tab (One excel spreadsheet but each tab has say Jan, Feb). I've applied the rule and it works but I want it to pick up too if there was any duplicate entry from previous months (e.g I'm entering data for Feb and I'd like to pick up if there was any same invoice number already entered in previous months or tabs). Thanks

    • I have the same issue - did you find a solution?

  39. Am trying to prevent duplicates in a column of cells in our project log sheets. Each entry contains eight characters, with the first five being able to repeat, but the last three must be unique and sequential (i.e. JR157001, KR257002, ST457003, etc). We continue to get the last three duplicated with the first five being different and it throws everything into chaos when 10-15 entries later you duplicate an existing entry, then all outside files (other software) with the incorrect numbers have to be reworked, wasting a lot of time. I have tried COUNTIF and a few others, but there is always something no right with the formulas. Thanks.

  40. MUCH EASIER WAY:

    CLICK FILTER ADVANCED BUTTON

    SELECT COLUMN YOU WISH TO APPLY FILTER TO

    CHECK THE BOX LABELED "UNIQUE RECORDS ONLY"

    YOU ARE DONE, BOW THE DUPLICATES ARE ELIMINATED AND YOU CAN EMAIL YOUR PEOPLE

  41. HI ,

    Could you help me for combine multiple excel ( Car booking data) in one sheet.

    Thanks

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 :)