Solved

# Multiple criteria Custom Data Validation

Posted on 2013-06-21
318 Views
I have a spreadsheet where the range of cells (E6:E12) must be the numbers 1 through 7 with each number only being used once.  I have added custom validation to the range to not allow duplicates:

=COUNTIF(\$E\$6:\$E\$12, E6)=1

And that is working fine.  Is there a way I can add a second criteria that the number must be with the range of 1 to 7.  Or what would the VBA code be to do this check?
0
Question by:amy_goe

LVL 23

Accepted Solution

NBVC earned 500 total points
ID: 39266969
Try

=AND(E6>=1,E6<=7,COUNTIF(\$E\$6:\$E\$12, E6)=1)

if you want to ensure only whole numbers are used, then:

=AND(MOD(E6,1)=0,E6>=1,E6<=7,COUNTIF(\$E\$6:\$E\$12, E6)=1)
0

Author Closing Comment

ID: 39267135
PERFECT!  Thank you so much!!
0

## Featured Post

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.