GoalExplain how a validation rule limits what can be typed in a cell, and write rules for type, length and range.
New words
validation · a check that a spreadsheet makes on data when it is typedvalidation rule · a rule that data must follow, such as ‘a whole number from 1 to 99’error message · a message that says the data was refused and what to type insteadvalid · data that follows the rule
Explanation
Data validation checks data when it is typed. We select the cells and choose a rule. A rule can limit the data type, such as ‘a date’. It can limit the length of text, such as ‘exactly 5 characters’. It can limit the range of a number, such as ‘a whole number from 1 to 99’. If the data breaks the rule, the spreadsheet refuses it and shows an error message. Validation cannot tell whether data is true. A shirt number of 71 is valid even when the player wears 17, so important data must still be checked.
Worked examples
Field
Entry
Accepted?
Why
Kit code
K-101
yes
5 characters
Kit code
K-1012
no
6 characters
Number in store
250
no
more than 200
Number in store
forty
no
not a number
Date bought
12 Feb 2026
yes
a date
The kit store sheet has three rules. Kit code: text, exactly 5 characters. Number in store: a whole number from 0 to 200. Date bought: a date. Here is what happens to some entries.
Poor message
Better message
Error
Type a whole number from 0 to 200.
Not allowed
The kit code needs exactly 5 characters.
Wrong
Please type a date, such as 12 Feb 2026.
A clear error message helps the person to fix the mistake.
Player
Real shirt number
Typed
Valid?
Correct?
Dina
17
17
yes
yes
Omar
17
71
yes
no
A validation rule cannot find every mistake. The shirt number rule is a whole number from 1 to 99. Both entries are valid, but only one is right.
Class activity
Gatekeeper (3 or more players). One player is the gatekeeper and holds a rule card, such as ‘a whole number from 1 to 12’. The other players hand over slips of paper with entries: 7, 13, July, 3.5, 12. The gatekeeper accepts or refuses each slip and, if refusing, reads out a helpful error message. Then change the rule, for example to ‘text of exactly 4 letters’. Invent rules of your own for a library card or a sports club. Which rules were hard to explain in a message?
Practice
1
The rule for ‘Page number’ is a whole number from 1 to 30. Which of these are accepted? 5, 31, 0, 12.5, 30
Field
Rule
Page number
whole number from 1 to 30
5 and 30. The others are above 30, below 1 or not whole.
2
Write a validation rule for each field: (a) age of club members, who are 5 to 12 years old, (b) a locker code of four characters, (c) the date of a match.
(a) a whole number from 5 to 12 (b) text with exactly 4 characters (c) data type date
3
Which entry will cause an error?
Field
Rule
Entries
Team code
text, exactly 3 characters
LIO, TIGER, FOX
TIGER. The rule needs exactly 3 characters, and TIGER has 5. LIO and FOX are accepted.
4
Write a helpful error message for a cell that accepts whole numbers from 0 to 50.
For example: ‘Please type a whole number from 0 to 50.’ A helpful message says what to type.