Microsoft KB Archive/189005

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

Article ID: 189005

Article Last Modified on 11/1/2000

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q189005





SUMMARY
This article explains how to use data validation to prevent you from making duplicate entries in a list.



MORE INFORMATION
The following example uses data validation to prevent duplicate entries from being entered in cell A1 to cell A50. To do this, you need set up two validation rules: one for the first cell in the list, and one for the rest of the cells. To create the example, follow these steps:

 Save and close any open workbooks, and then create a new workbook. Select cell A1, and then click Validation on the Data menu. In the Allow list, click Custom. Type the following formula in the Formula box:

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

 Click the Error Alert tab. In the Title box, type the title of the error message. In the Error Message box, type the error message that you want the user to see. In the Style list, click Stop. Click OK to apply the validation rule to cell A1. Select cells A2:A50, and then click Validation on the Data menu. Click the Settings tab. In the Allow list, click Custom. 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 title of the error message. In the Error Message box, type the error message that you want the user to see. In the Style list, click Stop. 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 will receive an error message. Clicking Retry allows you to change the cell entry. Clicking Cancel removes the cell entry.

For additional information about data validation, please click the article number(s) below to view the article(s) in the Microsoft Knowledge Base:

159252 XL97: Description and Examples of Data Validation

<div class="references_section">