![](http://1.bp.blogspot.com/-pSZgcQmbOqA/WB45fn8CsuI/AAAAAAAALpY/eQYcgckoyJAFDhUUbFUaU6Ln8hMpnu_-ACLcB/s1600/MS-Excel-Guide.png)
The below example show you how to use data validation to prevent users from entering duplicate values.
1. Select the range A2:A20.
![](http://1.bp.blogspot.com/-VSHM7kjEJx4/WB44VmKhuEI/AAAAAAAALpI/xzEL4-54InYAUnmVJ4dynjMe93z9DHr0gCLcB/s1600/prevent-duplicate-entries-in-excel-1.png)
2. On the Data tab, click Data Validation.
![](http://2.bp.blogspot.com/-2OwUKZxzsF8/WB44VpXN9NI/AAAAAAAALpE/zYO3HH4_KsAjKgEAMnPAL61HgJ3S38iPgCLcB/s1600/prevent-duplicate-entries-in-excel-2.png)
3. In the Allow list, click Custom.
4. In the Formula box, enter the formula shown below and click OK.
![](http://4.bp.blogspot.com/-gIwUdIBqQE8/WB44VsCEZlI/AAAAAAAALpA/jEf-sCAZmMMoWA8EwcjGJptUR_pgAaqlQCLcB/s1600/prevent-duplicate-entries-in-excel-3.png)
Explanation: The COUNTIF function takes two arguments. =COUNTIF($A$2:$A$20,A2) counts the number of values in the range A2:A20 that are equal to the value in cell A2. This value may only occur once (=1) since we don't want duplicate entries. Because we selected the range A2:A20 before we clicked on Data Validation, Excel automatically copies the formula to the other cells. Notice how we created an absolute reference ($A$2:$A$20) to fix this reference.
5. To check this, select cell A3 and click Data Validation.
![](http://4.bp.blogspot.com/-TcMTGRyuw7I/WB44V5P_hTI/AAAAAAAALpQ/lrjcXR9uDD47HfEnEnKOHjCW-FB-4NpuQCLcB/s1600/prevent-duplicate-entries-in-excel-4.png)
As you can see, this function counts the number of values in the range A2:A20 that are equal to the value in cell A3. Again, this value may only occur once (=1) since we don't want duplicate entries.
6. Enter a duplicate invoice number.
Result. Excel shows an error alert. You've already entered that invoice number.
![](http://1.bp.blogspot.com/-RaP-bVgdJ5s/WB44WDK3QEI/AAAAAAAALpM/FcnoXsi0N7cz4-hZ7-_ws9yefi1ifaYaQCLcB/s1600/prevent-duplicate-entries-in-excel-5.png)
Note: to enter an input message and error alert message, go to the Input Message and Error Alert tab.