Sub topic 16
Controlling Input with Data Validation
Assume you can select ranges, enter formulas, and recognize basic data types such as text, numbers, and dates. In Google Sheets, data validation is a rule that checks what someone may enter in a cell. It can provide a dropdown, require a checkbox, or reject values that do not meet a condition.
Add a dropdown list
Suppose a task tracker has a Status column. A dropdown prevents variations such as In progress, in-progress, and Working from becoming separate categories.
- Select the cells, such as
C2:C100. - Choose Data > Data validation > Add rule.
- Set the rule to Dropdown.
- Add options such as
Not started,In progress, andDone. - Choose whether invalid entries are rejected or only shown with a warning.
- Select Done.
Apply the rule to a range that includes future rows, but avoid applying it to a whole column if the sheet contains unrelated content.
A dropdown can use values entered directly in the rule or values from another range. A range-based list is useful when the allowed options change over time. Keep the source list controlled, because changes to that list affect every dropdown using it.
Use checkboxes for yes-or-no input
Select a range and choose Insert > Checkbox. Each cell then stores either TRUE or FALSE, even though the sheet displays a checked or unchecked box. This makes checkboxes useful in formulas and filters.
For example, if D2:D100 contains checkboxes, this formula counts completed items:
=COUNTIF(D2:D100,TRUE)Do not type words such as Yes into a checkbox column. Text does not behave like the checkbox’s Boolean values.
Validate numbers, dates, and custom rules
In a validation rule, choose conditions such as Number > 0, Date is valid, or Text contains. These rules protect calculations from unexpected input.
For a custom formula, select Custom formula is. If the rule applies to B2:B100, this formula accepts only numeric entries:
=ISNUMBER(B2)The reference B2 is relative to the top-left cell of the applied range. Sheets adjusts it for each row. If you write $B$2, every row checks only B2, which is usually an error.
You can combine conditions. To require a positive number, use:
=AND(ISNUMBER(B2),B2>0)Leave Show warning enabled when people may need to enter exceptions. Choose Reject input when inconsistent values would damage reports or formulas.
Understand the validation flow
Common errors include applying the rule to the wrong range, forgetting that blank cells may still be allowed, and using a custom formula whose references point to the wrong row. Test valid, invalid, and blank entries before sharing the sheet.
Exercise
You need a Priority column that accepts only the numbers 1 through 3. What custom formula should you apply to B2:B100?
Show answer
Use =AND(ISNUMBER(B2),B2>=1,B2<=3) and set invalid entries to be rejected.