Sub topic 16
Controlling input with data validation
Data validation is a rule attached to a cell or range that checks what a user enters. A rule can reject a bad entry, warn about it, or limit the choices to a list. This chapter assumes you can select ranges, enter values and formulas, and tell the difference between a stored value and its displayed format. Those topics come from earlier chapters.
What validation does and does not do
Validation checks input at the moment someone types, pastes a value from the keyboard into a cell, or picks from a dropdown. It does not change the value. It also does not check data that was already in the cell before you added the rule.
Keep these limits in mind:
- Existing invalid values stay in place. Sheets marks them with a small red triangle in the corner of the cell, but it does not remove them.
- Pasting can bypass a rule. Pasting normally copies the source cell's validation rule over the destination's rule. Pasting with Paste special > Values only puts the value in without checking it.
- Rules apply to cells, not to people. Anyone with edit access can open Data > Data validation and remove the rule.
- Formulas are not checked. A cell that holds a formula is not validated against its result.
Validation is a guide for honest mistakes. It is not a security feature. If you need to stop edits, use protected ranges.
Creating a rule
- Select the range, for example
B2:B100. - Choose Data > Data validation, then Add rule.
- Pick a criteria type.
- Choose what happens on invalid data: Show a warning or Reject the input.
- Optionally turn on help text, then click Done.
The range matters. Select the whole input area at once, so every cell follows the same rule. Setting rules one cell at a time leads to gaps.
Reject or warn
| Option | Effect | Use it when |
|---|---|---|
| Reject the input | The entry is refused and a message appears. | The value must be valid, such as a status code. |
| Show a warning | The entry is accepted, but the cell gets a red triangle. | Exceptions are allowed, and you want to see them. |
Warnings are useful for exploratory sheets. Rejection is better for sheets that feed other formulas.
Criteria types
The criteria list has several families.
- Dropdown and Dropdown (from a range) limit entries to a fixed list.
- Number accepts values that are between two numbers, greater than a number, equal to one, and so on.
- Text checks whether the entry contains, does not contain, equals, or looks like an email address or URL.
- Date accepts a valid date, or a date before, after, or between given dates.
- Checkbox turns a cell into a checkbox that stores
TRUEandFALSEby default. - Custom formula is accepts the entry only if your formula returns
TRUE.
Number and date rules use stored values
A number rule tests the stored value, not what you see on screen. If a cell displays $1,234.50 because of a number format, the rule still sees 1234.5. A date rule works the same way, using the underlying serial number of the date. This is why a Date rule is more reliable than a Text rule for date columns.
It also means locale matters. A rule that requires a valid date depends on how Sheets interprets what was typed, and that depends on the spreadsheet's locale. In some locales, 03/04/2026 is March 4. In others, it is April 3. Check File > Settings when a date rule rejects entries that look right.
Dropdown lists
A dropdown is the most common use of validation. There are two sources for the items.
- Dropdown lets you type items directly into the rule. Each item can also have a color.
- Dropdown (from a range) reads the items from cells, such as
Lists!A2:A10.
The range-based version is easier to maintain. You edit the list cells and every dropdown that points at them updates. A direct list is fine when the choices are few and rarely change.
Some points to watch:
- Matching is exact in meaning but not in case for typed entries. If a list item is
Open, typingopenis generally accepted, but check the result against your lookup formulas. - If you rename a list item, cells that already contain the old text keep it. They become flagged as invalid. Use find and replace to update them.
- A trailing space in a list item creates an item that looks like another one. Run
=TRIM(A2)on imported lists before using them as a source. - Blank cells in the source range can show up as empty choices. Select only the filled cells.
Dropdown chips can show colors and let users pick several items when multiple selection is enabled. With multiple selection, the cell holds the chosen items as one comma-separated text value. If you later need them separately, split them with =SPLIT(A2,",").
Checkboxes
A checkbox rule makes a cell hold one of two values. By default these are TRUE and FALSE. You can set custom values, such as Yes and No, in the rule options.
A checkbox cell can be used directly in a formula. For example, =IF(C2, "Done", "Open") returns Done when the box is checked. Clearing a checkbox cell with Delete sets it to unchecked.
Custom formula rules
A custom formula is a formula that returns TRUE for valid input. Write it for the first cell of the range, using relative references. Sheets adjusts the references for each other cell, in the same way as for conditional formatting.
For B2:B100, this rule accepts only numeric entries:
=ISNUMBER(B2)Here B2 is relative, so for B3 the rule checks B3. If you want every row to compare against one fixed cell, use an absolute reference, such as $E$1.
More examples, each written for a rule applied to B2:B100:
=AND(ISNUMBER(B2), B2>=0, B2<=100)
=COUNTIF($B$2:$B$100, B2)=1
=LEN(B2)=6The first accepts numbers from 0 to 100. The second accepts a value only if it appears once in the range, which blocks duplicates. The third accepts exactly six characters.
Common custom formula mistakes
- Referencing the wrong starting cell. The formula must use the top-left cell of the selected range.
- Missing
$signs on a fixed range. TheCOUNTIFrange above must be absolute, or it shifts down the column. - Forgetting the leading equals sign. Without it, the rule does not work as a formula.
- Writing a formula that returns text or a number instead of
TRUEorFALSE.
Help text and invalid-data messages
Turn on Show validation help text to display a short hint when a user selects the cell. It works best when it states the rule in plain words, for example "Enter a whole number from 1 to 5". With Reject the input, the same text appears in the error message, so make it useful in both places.
Finding and changing rules
Select a cell and open Data > Data validation. The side panel lists all rules that cover the selection. You can edit a rule's range or criteria, or remove it. If two rules overlap on a cell, the rule listed first takes priority, so check the order when behavior surprises you.
Combining validation with other tools
Validation works well with the features covered in neighboring chapters.
- Pair a status dropdown with conditional formatting so each status gets its own fill color. Use a rule such as
=$C2="Late"on the whole row. - Use a date rule on input columns so that formulas such as
=TEXT(A2,"yyyy-mm-dd")always get real dates. - Use find and replace to repair cells flagged after a list changes.
Edge cases
- Undo. Undo reverts a rejected-and-retyped change like any other edit, and removing a rule can be undone with Ctrl+Z or Cmd+Z.
- Inserted rows. Inserting a row inside a validated range extends the rule to it. Inserting directly below the last row does not.
- Copy and fill. Dragging the fill handle copies the rule along with the value. If you only want the values, use paste special.
- Imported data. Data imported from a file is not checked on import. Add the rule afterward and look for the red triangles.
Exercise
A column of order quantities, B2:B100, must hold whole numbers from 1 to 50, and no quantity may repeat within a day-file you are building. Write one custom formula rule for B2:B100 that enforces the range and rejects non-numbers and duplicates. Which setting should you pick if you want bad entries refused, not just flagged?
Show answer
Use =AND(ISNUMBER(B2), B2=INT(B2), B2>=1, B2<=50, COUNTIF($B$2:$B$100, B2)=1). B2 is relative so each cell checks itself, and the COUNTIF range is absolute so it stays fixed. Choose "Reject the input" in the invalid-data setting so bad entries are refused.
Exercise
You add a dropdown rule to a column that already contains the value "Pending", which is not in the list. What do you see, and what happens to the value?
Show answer
The cell with "Pending" gets a red triangle marking it as invalid, but the value is not changed or removed. Validation only checks new input, so you must fix or replace the existing value yourself, for example with find and replace.