Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: How to Use Data Validation to Prevent Duplicate Entries


View products that this article applies to.

This article was previously published under Q213185

↑ Back to the top


Summary

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

↑ Back to the top


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:
  1. Save and close any open workbooks, and then create a new workbook.
  2. Select cell A1 and click Validation on the Data menu.
  3. In the Allow list, click Custom, and then type the following formula in the Formula box:
    =ISERROR(MATCH(A1,A2:A50,0))
  4. 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.
  5. In the Style list, click Stop, and then click OK to apply the validation rule to cell A1.
  6. Select cells A2:A50, and then, on the Data menu, click Validation.
  7. 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))
  8. 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.
  9. In the Style list, click Stop, and then click OK to apply the validation rule to cells A2:A50.
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.

↑ Back to the top


References

For additional information about data validation, click the article number below to view the article in the Microsoft Knowledge Base:
211485� XL2000: Description and Examples of Data Validation
For more information about data validation, click Microsoft Excel Help on the Help menu, type troubleshoot data validation in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB213185, kbinfo, kbhowto, kbdtacode

↑ Back to the top

Article Info
Article ID : 213185
Revision : 6
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 287