Search Contextures Sites

Excel Data Validation Examples Custom Criteria

Prevent Duplicates With Data Validation
Limit the Total
No Leading or Trailing Spaces
Prohibit Weekend Dates

Prevent Duplicates With Data Validation

You can use Excel Data Validation to prevent duplicate entries in a range on the worksheet. In this example, Employee Numbers will be entered in cells B3:B10, and you can prevent the same number from being entered twice..

  1. Select cells B3:B10
  2. Choose Data|Data Validation
  3. Choose Allow: Custom
  4. For the formula in this example, we use the COUNTIF function to count the occurrences of the value in cell B3, in the range $B$3:$B$10. The formula's result must be 1 or 0:
       =COUNTIF($B$3:$B$10,B3) <= 1
   data validation 01


Limit the Total

Prevent the entry of a value that will cause a range to exceed a set total. In this example, the total budget cannot exceed $3500. The budget amounts are in cells C3:C7, and the formula checks the total in those cells

  1. Select cells C3:C7
  2. Choose Data|Data Validation
  3. Choose Allow: Custom
  4. For the formula, use SUM to total the values in the range $C$3:$C$7. The result must be less than or equal to $3500:
       =SUM($C$3:$C$7) <= 3500

  data validation 02

No Leading or Trailing Spaces

You can prevent users from adding spaces before or after the text in the entry. The TRIM function removes spaces before and after the text. The formula in this example checks that the entry in cell B2 is equal to the trimmed entry in that cell.

  1. Select cell B2
  2. Choose Data|Data Validation
  3. Choose Allow: Custom
  4. For the formula, enter:
       =B2 = TRIM(B2)

  data validation 03

Prohibit Weekend Dates

Prevent entry of dates that fall on Saturday or Sunday. The WEEKDAY function returns the weekday number for the date entered, and values of 1 (Sunday) and 7 (Saturday) are not allowed.

  1. Select cell B2
  2. Choose Data|Data Validation
  3. Choose Allow: Custom
  4. For the formula, enter:
  data validation 04
=AND(WEEKDAY(B2) <> 1, WEEKDAY(B2) <> 7)

Excel Tutorials - Data Validation

   

Data Validation Basics
Data Validation - Create Dependent Lists
Data Validation - Dependent Dropdowns from a Sorted List  
Data Validation - Dependent Lists With INDEX  
Hide Previously Used Items in a Dropdown List
Data Validation - Display Messages to the User
Data Validation - Display Input Messages in a Text Box 
Data Validation - Use a List from Another Workbook
Data Validation Criteria Examples
Data Validation Custom Criteria Examples
Data Validation Tips
Data Validation Documentation
Data Validation Combo Box     
Data Validation Combo Box - Named Ranges
Data Validation Combo Box -- Click
Data Validation - Add New Items  

       Home     Excel Tips     Excel Files     The Excel Store     Blog     Contact

 

Privacy Policy

 

Contextures Inc., Copyright ©2010
All rights reserved.

 

Last updated: April 10, 2010 8:16 PM