# Data validation unique values only

=COUNTIF(range,A1)<2

To allow only unique values in a given range, you can use data validation with a custom formula based on the COUNTIF function. In the example shown, the data validation applied to C5:C9 is:

=COUNTIF(emails,C5)<2

where *emails* is the named range C5:C9.

Data validation rules are triggered when a user adds or changes a cell value. In this example, we are using a formula that checks that the input doesn't already exist in the named range "emails":

COUNTIF(ids,B5)<2

COUNTIF returns a count of the value in C5 inside the named range *emails* (C5:C9). If the count is less than 2, the expression returns TRUE and validation succeeds. If not, the expression returns FALSE and validation fails.

*Note: Cell references in data validation formulas are relative to the upper left cell in the range selected when the validation rule is defined, in this case B5.*

## Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

## Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.