Sub topic 6
Validate numbers, text and dates with built-in criteria
This chapter assumes you can select ranges, enter values and basic formulas, and read references such as A2 and $A$2. It also assumes you have already opened the Data validation panel and know the difference between rejecting input and showing a warning. Here you will use the built-in criteria that check numbers, text, dates, email addresses and URLs without writing a formula.
What built-in criteria are
A criterion is the test a cell value must pass. Google Sheets ships with a set of ready-made tests. You choose one in the Criteria drop-down of the Data validation panel (Data > Data validation > Add rule). You then fill in the values the test needs.
The built-in criteria fall into these groups:
| Group | Criteria | Values you supply |
|---|---|---|
| Number | Greater than, Less than, Between, Not between, Equal to, Not equal to, Greater than or equal to, Less than or equal to | One number, or two for Between and Not between |
| Text | Contains, Does not contain, Is equal to, Is valid email, Is valid URL | Text to match, or nothing for email and URL |
| Date | Is valid date, Is equal to, Before, On or before, After, On or after, Is between, Is not between | A date, a relative date, or two dates |
Pick the group by choosing the criterion whose name matches what you want. A new rule is not active until you press Done, so check the range field first.
Number criteria
Number criteria compare the entered value with a limit you set. They accept only numeric values. A cell that holds text such as twelve fails every number criterion, even if the words describe a valid number.
A worked example: a column of quantities in B2:B100 must be a whole-looking figure between 1 and 500.
- Select B2:B100.
- Open Data > Data validation and choose Add rule.
- Set the criterion to Between.
- Enter
1and500in the two boxes. - Under Advanced options, choose Reject input.
- Press Done.
Typing 0, 501 or abc is now refused. Typing 2.5 is accepted, because Between checks the range and not whether the number is whole. To require whole numbers, you need a custom formula such as =AND(ISNUMBER(B2), B2=INT(B2)), covered in a later chapter.
Some details to keep in mind:
- Between includes both ends. A value of exactly 1 or exactly 500 passes.
- Not between also treats the two ends as inside the excluded range, so 1 and 500 fail.
- The limits can be cell references, for example
=Settings!B1. This lets you change a limit in one place and have every rule follow it. - A blank cell passes the rule. Validation checks values when they are entered. It does not require that a value exist. If a field is mandatory, validation alone cannot enforce it.
Text criteria
Text criteria test the characters in a cell.
- Contains passes when the entry includes your text anywhere. The match ignores upper and lower case.
- Does not contain is the reverse.
- Is equal to passes only when the entry matches your text exactly. Case is ignored here as well.
- Is valid email passes when the entry looks like an email address.
- Is valid URL passes when the entry looks like a web address.
The email and URL criteria check the shape of the entry. They do not check that the mailbox exists or that the page loads. Entering [email protected] passes. Entering name@example fails because the address has no dot-separated domain.
The URL check expects a recognizable top-level domain. example.com passes. http://localhost fails. If your team enters internal addresses, use a Contains rule or a custom formula instead.
A text example
Suppose column D holds order codes that must start with ORD-. The built-in Contains criterion with the text ORD- lets ORD-1042 pass, but it also lets OLD ORD-1042 pass, because it only looks for the text anywhere in the cell. When position matters, use a custom formula such as =LEFT(D2,4)="ORD-". This is the main limit of the built-in text criteria. They check presence, not position or pattern.
Date criteria
Dates in Sheets are stored as numbers, counted in days from a fixed starting point. Date criteria rely on that. An entry passes a date rule only if Sheets recognizes it as a date. If you type 31/02/2025, Sheets cannot read it as a real date, so the rule rejects it. Text that merely looks like a date can also be refused or accepted depending on your spreadsheet's locale. Check File > Settings > Locale if dates behave differently than you expect.
The date criteria are:
- Is valid date accepts any real date.
- Is equal to, Before, On or before, After, On or after compare with one date.
- Is between and Is not between compare with two dates.
For each comparison you choose how the limit is given. The panel offers a fixed date you pick, or one of these relative options: today, tomorrow, yesterday, in the past week, in the past month and in the past year. Relative dates are re-evaluated each time the sheet is used, so a rule set to On or before today always follows the current day.
A date example
A booking sheet needs a start date in B2:B100 that is not in the past:
- Select B2:B100.
- Choose Add rule and set the criterion to Date > On or after.
- Choose today from the date options.
- Set Reject input and add help text such as
Enter today's date or later. - Press Done.
Typing yesterday's date is refused. Typing tomorrow's date is accepted.
The Topic Spine's formula =AND(ISNUMBER(B2), B2>=DATE(2025,1,1), B2<=TODAY()) does the job of an Is between rule that runs from 1 January 2025 to today. The built-in version is easier to maintain. Use the formula only when the built-in options cannot express the condition.
How the pieces combine
Each range can hold one rule per cell at a time. If you add a second rule to cells that already have one, the new rule replaces the old one for the overlap. You cannot stack a number rule and a text rule on the same cell through the panel. When a cell needs two tests, combine them in one custom formula with AND.
The next diagram shows the decision a cell goes through when a user types a value.
Common errors and how to fix them
| Symptom | Likely cause | Fix |
|---|---|---|
| A valid number is refused | The cell holds text, for example `12` stored as text after a paste from another system | Re-enter the value, or convert the column with `VALUE` |
| A date is refused | The text does not match the spreadsheet's locale, such as day and month swapped | Check the locale, or enter dates with the date picker |
| A rule passes everything | The criterion is **Is valid date** or **Contains** with an empty text box | Fill in the value the criterion needs |
| A relative limit seems wrong | **today** is calculated when the sheet recalculates, not when the entry was made | Use a fixed date if the limit must not move |
| A rule limit does not update | The limit was typed as a number, not entered as a cell reference | Replace the typed limit with a reference such as `=Settings!B1` |
| Old bad values remain | Validation checks new entries only | Find existing bad data with a filter or a formula, then correct it |
The last row matters in practice. Adding a rule to a column that already holds data does not clean it. Cells with values that break the rule are marked with a small red triangle in the corner when the rule is set to show a warning. With Reject input, existing values stay in place and are not flagged, so review them yourself.
Choosing between built-in criteria and a custom formula
Use a built-in criterion when one of these holds:
- The test is a single comparison with a number, a date or a piece of text.
- Other people will edit the rule and need to read it at a glance.
- You want the date picker to appear on date cells.
Switch to a custom formula when you need to test position or pattern in text, require whole numbers, combine two tests, or compare the cell with other cells in the same row. Built-in rules are easier to read. Custom rules are more flexible but harder to debug.
A complete worked sheet
Consider a small expense log with three input columns.
| Column | Contents | Rule |
|---|---|---|
| A | Claimant email | Text > Is valid email |
| B | Expense date | Date > Is between a fixed start date and **today** |
| C | Amount | Number > Greater than 0 |
Apply each rule to rows 2 through 200, using Reject input for dates and amounts and Show warning for emails, since an unusual but real address should still be allowed with a flag. Add help text to each column so users see the expected format when they select a cell.
Test the setup by entering one bad and one good value in each column. Check that a future date is refused, that -5 is refused in column C, and that someone@ in column A is kept but flagged. This habit of testing each edge catches mistakes in the limits, such as using Greater than where you meant Greater than or equal to.
Summary of what to remember
- Built-in criteria cover numbers, text, dates, email and URL checks without formulas.
- Blank cells always pass.
- Text criteria check presence, not position, and ignore case.
- Date rules need real dates, and relative options such as today move with the calendar.
- Limits can come from cells, which keeps rules easy to change.
- Rules apply to new entries and do not repair existing data.
Exercise
A column E2:E50 must accept only dates from the start of this year through today, and users must be told why an entry is refused. Which built-in criterion and settings do you use, and why can it not make the cell mandatory?
Show answer
Select E2:E50 and add a rule with the Date criterion "Is between". Enter the first day of the year as a fixed date and choose "today" as the second date. Under Advanced options choose "Reject input" and write help text such as "Enter a date from 1 January to today." The rule cannot make the cell mandatory because validation tests only values that are entered, and a blank cell passes every built-in criterion.
Exercise
Order codes in D2:D100 must begin with "ORD-". A colleague used the built-in "Contains" criterion with the text "ORD-", yet the entry "OLD ORD-17" is accepted. Explain why, and give a replacement rule.
Show answer
"Contains" is true when the text appears anywhere in the cell, so "OLD ORD-17" passes. Replace the rule with a custom formula applied to D2:D100: =LEFT(D2,4)="ORD-". This tests the first four characters, so only entries that start with the prefix pass.
Exercise
You add a "Number > Between 1 and 500" rule with "Reject input" to a column that already contains the values 0, 250 and 900. What happens to those three values?
Show answer
All three stay in the cells, because validation checks new entries only and does not change or remove existing data. The values 0 and 900 break the rule, but with "Reject input" they are not flagged. To find them, use a filter or a helper formula such as =OR(B2<1, B2>500).