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
- Select the cells where you want to apply data validation.
- Go to the Data tab on the ribbon.
- Click on Data Validation in the Data Tools group.
- 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:
- Select cells.
- Open the Data Validation dialog.
- Under Allow, select Whole number.
- 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:
- Select cells.
- Open the Data Validation dialog.
- Under Allow, select Date.
- Set the Start date to
01/01/2023
and End date to12/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:
- Select cells.
- Open the Data Validation dialog.
- Under Allow, select List.
- 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:
- Select cells.
- Open the Data Validation dialog.
- Under Allow, select Text Length.
- 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:
- Select cells.
- Open the Data Validation dialog.
- Under Allow, select Custom.
- Enter a formula like:
=A1+B1
.
- Result: Ensures that the value entered meets the formula condition.
Tips for Data Validation
- Input Messages: Add instructions to the Input Message tab to guide users about the data they can enter.
- Error Alerts: On the Error Alert tab, customize messages to show when users enter invalid data.
- Copy Validation Rules: Use the Format Painter to apply the same validation rules to other cells.
Example Use Case
Product | Price | Quantity |
---|---|---|
Apple | 100 | 5 |
Orange | 80 | 2 |
- 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