Microsoft KB Archive/213185

= XL2000: How to Use Data Validation to Prevent Duplicate Entries =

Article ID: 213185

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q213185





SUMMARY
This article explains how to use data validation to prevent the creation of duplicate entries in a list.



MORE INFORMATION
The following example uses data validation to prevent duplicate entries from being entered within the range of cells A1 through A50. To create the example, you need set up two validation rules: one for the first cell in the list, and one for the rest of the cells. To do so, follow these steps:  Save and close any open workbooks, and then create a new workbook. Select cell A1 and click Validation on the Data menu. In the Allow list, click Custom, and then type the following formula in the Formula box:

=ISERROR(MATCH(A1,A2:A50,0))

 Click the Error Alert tab, type the error message title that you want the user to see in the Title box, and then type the error message that you want the user to see in the Error Message box. In the Style list, click Stop, and then click OK to apply the validation rule to cell A1. Select cells A2:A50, and then, on the Data menu, click Validation.</li> On the Settings tab, click Custom in the Allow list, and then type the following formula in the Formula box:

=ISERROR(MATCH(A2,INDIRECT("$A$1:$A$"&ROW-1),0))

</li> Click the Error Alert tab. In the Title box, type the error message title that you want the user to see, and then in the Error Message box, type the error message that you want the user to see.</li> In the Style list, click Stop, and then click OK to apply the validation rule to cells A2:A50.</li></ol>

As you make entries into cells A1:A50, Excel applies the validation rules that you have established. If you make a duplicate entry, you receive an error message. Clicking Retry allows you to change the cell entry, and clicking Cancel removes the cell entry.

<div class="references_section">