Setting up data validation rules in excel with examples

Setting Up Data Validation Rules in Excel

Data validation is a feature in Excel that allows you to control the type of data entered into a cell or range. You can restrict users to entering specific values, dates, text lengths, or even formulas.


How to Set Up Data Validation

  1. Select the cells where you want to apply data validation.
  2. Go to the Data tab on the ribbon.
  3. Click on Data Validation in the Data Tools group.
  4. In the Data Validation dialog box:
    • Settings tab: Choose the criteria for the validation.
    • Input Message tab: Add a message to guide users on what to enter.
    • Error Alert tab: Customize the error message for invalid data entries.

Examples of Data Validation Rules

1. Restrict to Whole Numbers

  • Scenario: Allow users to enter whole numbers between 1 and 100.
  • Steps:
    1. Select cells.
    2. Open the Data Validation dialog.
    3. Under Allow, select Whole number.
    4. Set the Minimum to 1 and Maximum to 100.
  • Result: Only numbers like 5, 42, or 99 can be entered. Decimals or numbers outside this range will show an error.

2. Restrict to Dates

  • Scenario: Allow only dates between January 1, 2023, and December 31, 2023.
  • Steps:
    1. Select cells.
    2. Open the Data Validation dialog.
    3. Under Allow, select Date.
    4. Set the Start date to 01/01/2023 and End date to 12/31/2023.
  • Result: Users can only enter dates in 2023. Other dates will trigger an error.

3. Create a Dropdown List

  • Scenario: Allow users to select from a predefined list of options (e.g., “Yes”, “No”, “Maybe”).
  • Steps:
    1. Select cells.
    2. Open the Data Validation dialog.
    3. Under Allow, select List.
    4. In the Source field, type: Yes,No,Maybe (or reference a range like =$A$1:$A$3).
  • Result: A dropdown appears in the cell with these options.

4. Restrict to a Text Length

  • Scenario: Limit input to text with a maximum of 10 characters.
  • Steps:
    1. Select cells.
    2. Open the Data Validation dialog.
    3. Under Allow, select Text Length.
    4. Set Maximum to 10.
  • Result: Users cannot enter text longer than 10 characters.

5. Use a Formula for Validation

  • Scenario: Restrict data based on a formula (e.g., only allow values greater than the sum of two other cells).
  • Steps:
    1. Select cells.
    2. Open the Data Validation dialog.
    3. Under Allow, select Custom.
    4. Enter a formula like: =A1+B1.
  • Result: Ensures that the value entered meets the formula condition.

Tips for Data Validation

  1. Input Messages: Add instructions to the Input Message tab to guide users about the data they can enter.
  2. Error Alerts: On the Error Alert tab, customize messages to show when users enter invalid data.
  3. Copy Validation Rules: Use the Format Painter to apply the same validation rules to other cells.

Example Use Case

ProductPriceQuantity
Apple1005
Orange802
  • Validation Rules:
    • Price: Restrict to numbers between 50 and 200.
    • Quantity: Dropdown with 1, 2, 3, 4, 5.

This ensures consistent and error-free data entry.

Download Sample File from here : https://github.com/slidescope/data/blob/master/Data_Validation_Sample.xlsx