Duplicates aren’t always a bad thing — sometimes they’re valid entries. But when they’re not, duplicate values return erroneous summaries and totals. The good news is that you can easily prevent duplicates in a specific range using Excel’s Validation feature as follows:

  1. Select the range of cells in which you want to prevent duplicate values.
  2. Choose Validation from the Data menu. In Excel 2007, click the Data tab and choose Data Validation from the Data Validation option’s drop-down list (in the Data Tools group).
  3. Click the Settings tab.
  4. Choose Custom from the Allow drop-down list.
  5. Enter a formula in the following form into the Formula control:=COUNTIF($range,firstcellinrange) = 1

  6. Click the Error Alert tab.
  7. Enter the text Duplicate Entry in the Title control.
  8. In the Error Message box, enter a meaningful description, such as The value is a duplicate value and therefore, not valid.
  9. Click OK.

If you attempt to enter a duplicate value, Excel will reject it. When this happens, click Cancel to clear the error message and enter a valid value.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays