How To Prevent Duplicate Data Entries

Get The Completed Workbook

 

Suppose we have some data for an employee list that will continually be updated and we want to make sure that any user adding to the list doesn’t add a duplicate entry. In this post we’ll learn how to use data validation to prevent a user from entering a value if it’s already been entered in the table.

 

In our example we have a simple set of data that contains a field for employee ID, name and address and we will prevent any duplicated employee ID’s being entered. Our data has also been turned into a table and the table has been named EmployeeData. If you want to read how to create a table in Excel, please read thisย Introduction To Excel Tables.

 

 

Add a custom validation criteria. This will allow us to write a formula to test whether the data is valid or not. In this case we will enter a formula to count how many times the value appears in the list and limit it to 1.

  1. Select the full column of data which we’re going to limit to unique values.
  2. Go to the Data tab.
  3. Press the Data Validation button.
  4. Select Data Validation from the drop down menu.
  5. Select the Settings tab.
  6. In the Allow drop down select Custom.
  7. In the Formula area input this formula.
    =(COUNTIFS(INDIRECT("EmployeeData[Employee ID]"),A2)=1)

 

 

We can also add a warning message to users that will display when the active cell cursor is on a cell with this data validation.

  1. Go to the Input Message tab.
  2. Enter a Title for the input message.
  3. Enter a descriptive message that will warn the user about the data validation for unique values.
  4. When the active cell is in the range with this unique value data validation, the input message will display.

 

 

We can also add a error message that will display if the user does try to input a duplicate value.

  1. Go to the Error Alert tab.
  2. Select the style of pop up message, either Stop, Warning or Information.
  3. Enter a Title for the pop up message.
  4. Enter a descriptive message that will warn the user about their error.
  5. Press the OK button.
  6. Now if you try to enter a duplicate value, a pop up message box will alert you about your error of entering a duplicate value.

 

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and qualified actuary with over 15 years of experience. He has worked in a variety of industries, including insurance, ad tech, and most recently Power Platform consulting. He is a keen problem solver and has a passion for using technology to make businesses more efficient.

Related Posts

37 Awesome Excel Mouse Tips & Tricks You Should Know

37 Awesome Excel Mouse Tips & Tricks You Should Know

While the keyboard is generally quicker, you shouldn’t completely ignore the mouse. There are also some great time saving mouse shortcuts as well. In this post we’ll take a look at some of the best Excel mouse time saving tips and tricks.

read more
25 Amazing Power Query Tips and Tricks

25 Amazing Power Query Tips and Tricks

Power query is amazing tool that allows you to import and transform data with ease and helps to create repeatable and robust procedures with your data. Here are some tips and tricks to help you get the most out Power Query.

read more

Comments

0 Comments

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos ๐Ÿ˜ƒ