Pages

How to prevent duplicate entries in excel using Data Validation?

One of these days I had task where needed to build a matrix with quite a lot diferent product codes.
Of course, the remove duplicates function would have been a great work arround but these product codes where going to be keyed in one by one in diferent times and several people. So, I've found a way to add come conditions to the pre-designed matrix. To do so, I've used Data Validation funtion.
So, here is a quick and easy way to prevent duplicate entires in any table that you need to build in excel:

  1. You need to select your data range where you want the prevente entry of duplicates.
  2. After selecting the range, go to Data Tab and click on Data Validation
  3. The Data Validation Window will show. In the Settings Tab select Custom  and enter the following formula: =COUNTIF(range,criteria)<=1


Prevent duplicate entries in excel using Data Validation
To avoid duplicates in the table shown in this example, you'd have to enter the fórmula: = COUNTIF($A$1:$F$10,A1)<=1

Explaining the formula: =COUNTIF(range,criteria)<=1

The COUNTIF function will check the number of occurences in the defined range(including the value that you are keying in) is less than or equal to 1. If so, that means that no other cell in the range contains a value equal to the one you're keying in. In case this function returns a value higher than one, that means the you're trying to enter a duplicate value and in this case you'll get the following error:

Prevent duplicate entries in excel using Data Validation
As the value "10055" in already exiting in Cell A1, excel won't allow the user to enter the same value in cell B3.

And there you go!
Your table is now ready to prevent the entry of duplicate values.



No comments:

Post a Comment