Microsoft KB Archive/189006

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

Article ID: 189006

Article Last Modified on 9/11/2002

-

APPLIES TO


 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q189006





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 see the following article in the Microsoft Knowledge Base:

181323 XL98: Description and Examples of Data Validation

<div class="references_section">