Sub topic 6
Validate Numbers, Text and Dates with Built-in Criteria
Assume you can select cells and ranges, enter values, use basic formulas, and refer to cells such as A2 and $A$2. This chapter uses Google Sheets on a desktop browser. Data validation is a rule that checks what someone enters in a cell. Built-in criteria handle common checks without requiring a custom formula.
Open the validation rule
- Select the cells to protect, such as
B2:B100. - Select Data > Data validation.
- Select Add rule.
- Choose a criterion.
- Configure its values.
- Choose what should happen when the value fails.
- Select Done.
The cell reference in a criterion normally applies relative to the first cell in the selected range. For example, a date rule created for B2:B100 evaluates each row's value in column B.
Validate numbers
Choose a number criterion when a cell must contain a numeric value. Common choices include:
- Is equal to
- Is not equal to
- Is greater than
- Is greater than or equal to
- Is less than
- Is less than or equal to
- Is between
- Is not between
For example, select C2:C100 and choose Is between with minimum 0 and maximum 100. This accepts scores from 0 through 100, including both endpoints.
A number criterion checks numeric values, not merely characters that look numeric. A value such as 85 is normally numeric. A value imported as text may fail even though it displays as 85. Check the cell format and source data if apparently valid values are rejected.
Use a separate rule when the number represents a percentage, currency amount, quantity, or measurement. Validation checks the underlying value. For example, a percentage displayed as 25% has an underlying value of 0.25, so a rule requiring a value between 0 and 1 matches that representation.
Validate text
Text criteria are useful for codes, labels, and short descriptions. Available choices can include:
- Text contains
- Text does not contain
- Text starts with
- Text ends with
- Text is exactly
- Is valid email
- Is valid URL
For example, a rule on D2:D100 with Text starts with and value INV- accepts INV-1042 but rejects PO-1042. Text matching can be affected by spaces and spelling. A value with an extra trailing space may not match an exact-text rule.
Use Is valid email or Is valid URL for basic format checks. These criteria do not prove that an address exists or that a website is reachable. They only check whether the value resembles the expected format.
Validate dates
A date criterion checks whether a cell contains a valid date and, when requested, whether it falls within a time range. Useful choices include:
- Is valid date
- Is date
- Is date before
- Is date on or before
- Is date after
- Is date on or after
- Is date between
For a project tracker, select B2:B100, choose Is date between, and set the start and end dates. The rule then prevents dates outside the project window.
Google Sheets stores dates as numbers and displays them using a date format. A value can look like a date but actually be text. If the rule rejects it, re-enter the date, use Format > Number > Date, or convert imported text with a formula.
For a moving boundary, use a custom formula instead of a fixed date. Built-in criteria are best when the allowed range is constant and easy to edit in the rule panel.
=AND(ISNUMBER(B2), B2>=DATE(2025,1,1), B2<=TODAY())This rule accepts dates from 1 January 2025 through today. Apply it to B2:B100. Because B2 is relative, each row checks its own date.
Choose the criterion carefully
| Need | Suitable criterion | Example |
|---|---|---|
| Limit a score | Number is between | 0 through 100 |
| Require an identifier format | Text starts with | `INV-` |
| Restrict a schedule | Date is between | Project start and end |
| Check a basic web address format | Is valid URL | `https://example.com` |
Exercise
Exercise
You need E2:E100 to accept only dates from 1 January 2025 through today. Which rule should you use when the end date must update automatically?
Show answer
Use a custom formula rule with =AND(ISNUMBER(E2), E2>=DATE(2025,1,1), E2<=TODAY()), applied to E2:E100.