Prevent Duplicate Entries in Excel

When doing data entry work in Excel, you may want to prevent entering duplicate entries in a column or a range of cells.

Thankfully, there is a feature in Excel that allows you to do precisely this – and it’s called Data Validation.

In this article, I will show you how to prevent duplicate entries in Excel using Data Validation. I will also cover a method that instantly highlights duplicate entries using Conditional Formatting.

Prevent Duplicate Entries Using Data Validation

Below, I have a data set where I am entering names in column A, and I want Excel to prevent me from entering a duplicate name in the column:

Data set to prevent duplicate entries in Excel

Below are the steps to do this:

  1. Select the range of cells in which you want to prevent the duplicate entry. In this example, I will select the entire column A.
Select the entire column
  1. Click the Data tab.
  2. In the Data Tools group, click on the Data Validation icon. This will open the Data Validation dialog box.
Click on the data validation icon in the ribbon
  1. In the Settings tab, click the Allow drop-down and select the Custom option.
Click the custom option in the allowed dropdown in data validation to prevent duplicate entry
  1. In the formula field, enter the below formula.
=COUNTIF(A:A,A1)=1
And the formula to prevent duplicate entry

In the above formula, I have used A:A as the first argument of the COUNTIF function, but you can use any range on which you want to apply this data validation rule.

  1. Click the ok button.

Now, when you are doing a data entry in column A, and you repeat a name (or any text string that has already been entered in column A), it will show you an error prompt, as shown below.

Yellow box shown when you have duplicate entry in the range

How does this work?

Whenever you enter anything in any cell in column A, it checks whether it satisfies the formula we used in data validation.

The formula =COUNTIF(A:A,A1)=1 checks the content of the cell and counts whether the same also appears in any other cell or not.

If the cell content is unique, our formula would return TRUE, and Data Validation would allow you to make that entry in the cell. If more than one instance of that name appears in the column, our formula will return FALSE, and Data Validation will not allow us to enter that value by showing us the Error Prompt.

Customizing the Error Alert Dialog Box

You can customize the error dialog box to make it more useful for the user.

By default, the title of the dialog box says Microsoft Excel, but you can change it and make it something more meaningful such as ‘Duplicate Names Not Allowed’.

Here is how to do this:

  1. Open the Data Validation dialog box (Data tab –> Data Tools Group –> Data Validation).
  2. Set the Data Validation rule as covered in the previous section.
  3. Click the Error Alert tab
Select the error alert tab
  1. Enter the customized title and error message that you want to show on the Error Alert Dialog Box.
enter the customized title and description

Now, when you make a duplicate entry in the column, you will see a dialog box, as shown below.

Duplicate entry not allowed customized dialog box

Note: If you copy a cell and paste it over the cells where data validation rules have been applied, it will remove the data validation rules. So this method would only work if you are manually entering the data.

Also read: How to Create a Data Entry Form in Excel

Prevent Duplicate Entries By Highlighting Them

Another method that can be helpful in preventing duplicate entries is by highlighting the duplicate entry in a different color as soon as it is entered.

This can easily be done using Conditional Formatting.

Let me show you how it works.

Below, I have a dataset where I’m entering names and column A, and I want to prevent duplicate name entries in the column.

Data set to prevent duplicate entries in Excel

Here are the steps to highlight duplicate entries as soon as you type it:

  1. Select the column or range of cells in which you want to prevent duplicate entries. In this example, I’m going to select the entire column A.
  2. Click the Home tab.
  3. Click on the Conditional Formatting option.
Click on the conditional formatting icon in the ribbon
  1. Go to the Highlight Cell Rules option, and in the additional options that show up, select the Duplicate Values option.
Click on the duplicate values option
  1. This opens the Duplicate Values dialog box, where you can specify the formatting to be applied to cells that contain duplicate values. In this example, I will go with the default Light Red Fill with Dark Red Text. You can choose from any other pre-set formatting or create your own by clicking on the drop-down and then selecting Custom Format.
Duplicate values dialog box in conditional formatting
  1. Click OK

That’s it!

Now, as soon as you enter a name that is already there in column A, it will instantly highlight the cell in the specified format.

duplicate values are highlighted in the column
Also read: How to Highlight Blank Cells in Excel

So, these are two methods you can use to prevent duplicate entries in a column in Excel.

You can use Data Validation to stop the user from entering a duplicate entry by showing an error prompt or use Conditional Formatting that allows you to enter a duplicate value but highlights it so that you know it is a repeat of an existing value.

I hope you found this article helpful. If you have any feedback or suggestions for me, do let me know in the comments section.

Other Excel articles you may also like:

Excel Ebook Subscribe

FREE EXCEL BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Sumit Bansal
Hello there! I'm Sumit Bansal, founder of trumpexcel.com and an Excel MVP. I started this website in 2013 with a simple goal: to share my love for Excel through easy to follow tips, tutorials and videos. I'm here to help you get the best out of MS Excel to save time and boost your productivity.

3 thoughts on “Prevent Duplicate Entries in Excel”

  1. Love Excel, and you for your generous social service. Appreciate your effort to make us (the world) more productive.
    -Thilak Wijesinghe (Sri Lanka)

    Reply

Leave a Comment

Free-Excel-Tips-EBook-Sumit-Bansal-1.png

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free-Excel-Tips-EBook-Sumit-Bansal-1.png

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free Excel Tips EBook Sumit Bansal

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster