Excel course · Lesson 12 of 34
Data validation: drop-down lists and dependent lists
Stop bad data at the door: whole number, date and length rules, drop-down lists from tables, dependent drop-downs, input messages and error alerts.
Data validation controls what can be typed into a cell. It is the cheapest way to keep a shared workbook clean: instead of fixing Nrth, north and North after the fact, you give people a drop-down list. Instead of a quantity of -5 or ten, you allow only whole numbers from 1 to 500. This lesson covers the rule types, drop-down lists that grow automatically, dependent (cascading) lists, and the limits of validation.
Your first rule: whole numbers only
- Select the cells that will hold quantities, for example
D2:D100. - Choose Data › Data Tools › Data Validation (on Windows also
Alt,A,V,V). - On the Settings tab set Allow: Whole number, Data: between, Minimum: 1, Maximum: 500.
- On the Input Message tab type a title
Quantityand the messageEnter a whole number from 1 to 500.This appears as a small note when the cell is selected. - On the Error Alert tab choose Style: Stop, title
Invalid quantity, and a message explaining what is allowed. - Click OK. Try typing
0,12.5orten: Excel refuses each one.
Validation types
| Allow | Use it for | Example setting |
|---|---|---|
| Whole number | Quantities, ages, years | between 1 and 500 |
| Decimal | Prices, rates | between 0 and 1 for a percentage |
| List | Fixed choices | Source: North,South,East,West |
| Date | Order or due dates | greater than or equal to =TODAY() |
| Time | Shift start times | between 06:00 and 22:00 |
| Text length | Codes, postcodes | equal to 5 |
| Custom | Anything a formula can test | =COUNTIF($A:$A,A2)=1 (no duplicates) |
Minimum and maximum can be cell references or formulas, for example a date that must be after the order date in column B: Date, greater than or equal to, Start date =B2.
Drop-down lists
A short fixed list
- Select the Region column cells.
- Open Data › Data Validation, set Allow: List.
- In Source type
North,South,East,West(use semicolons if your regional settings use them as list separators). - Keep In-cell dropdown ticked and click OK. Each cell now has an arrow; pressing
Alt+Down Arrow(Mac:Option+Down Arrow) opens the list from the keyboard.
A list from cells that grows automatically
Typed lists are hard to maintain. Better: keep the items on a separate sheet, in an Excel table, and point the validation to it.
| A | |
|---|---|
| 1 | Products |
| 2 | Laptop |
| 3 | Monitor |
| 4 | Keyboard |
| 5 | Mouse |
| 6 | Headset |
On a sheet called Lists, a one-column table named tblProducts.
- On a sheet called
Lists, type the products, click inside and pressCtrl+Tto make a table. Name ittblProductsin Table Design › Table Name. - Validation cannot refer to a table column directly, so create a name: Formulas › Define Name, Name
ProductList, Refers to=tblProducts[Products]. - Select the input cells on your order sheet and open Data › Data Validation, Allow: List, Source:
=ProductList. - Add
Webcamat the bottom of the table. It appears in every drop-down immediately.
=Lists!$A$2:$A$6), but that fixed range does not grow. The name-over-table method does. In Microsoft 365 a third option is a spilled range, for example =Lists!$C$2# where C2 holds =SORT(UNIQUE(...)).Dependent (cascading) drop-down lists
A dependent list changes its choices based on another cell: pick a category in column A, and column B only offers products from that category.
| D | E | F | |
|---|---|---|---|
| 1 | Hardware | Software | Services |
| 2 | Laptop | Office suite | Installation |
| 3 | Monitor | Antivirus | Training |
| 4 | Printer | Accounting | Support plan |
On the Lists sheet: one column per category, the header is the category name.
Method 1: INDIRECT with names (all versions)
- Select
D1:F4and choose Formulas › Defined Names › Create from Selection, tick Top row only. This creates the namesHardware,SoftwareandServices, each pointing to its column of items. - Create the first list: select the Category cells (say
A2:A50on the order sheet), Data Validation › List, Source=Lists!$D$1:$F$1. - Create the dependent list: select
B2:B50, Data Validation › List, Source=INDIRECT(A2). Excel may warn that the source currently evaluates to an error because A2 is empty; click Yes to continue. - Pick
Softwarein A2. The drop-down in B2 now shows Office suite, Antivirus and Accounting.
INDIRECT turns the text in A2, such as Software, into a reference to the range with that name. Because the reference to A2 is relative, row 3 uses A3, row 4 uses A4, and so on. Category names must be valid names, so Office Supplies must become Office_Supplies (use =INDIRECT(SUBSTITUTE(A2," ","_")) if your categories contain spaces).
Method 2: FILTER on a two-column list (Microsoft 365)
With dynamic arrays you can keep all items in one long two-column table (Category, Item), which is easier to maintain. In a helper cell, say H2 on the Lists sheet, write =FILTER(tblItems[Item], tblItems[Category]=Orders!A2) and use =Lists!$H$2# as the validation source. The limitation is that the helper formula refers to one specific row, so this works best for a single input form rather than a long list of rows.
=COUNTIF(INDIRECT(A2),B2)=0 to flag mismatches.Error alert styles
| Style | What happens with invalid input |
|---|---|
| Stop | The entry is refused. The user must retry or cancel. |
| Warning | The user is asked 'Continue?' and may accept the value. |
| Information | A message appears but the value is accepted. |
Limits of data validation
- Validation checks only typed entries. Pasting over a validated cell replaces the rule along with the value, and invalid data gets in.
- Values that existed before the rule was created are not checked. Use Data › Data Validation › Circle Invalid Data to find them, and Clear Validation Circles to remove the marks.
- Formulas in validated cells are not validated.
- A list typed directly in the Source box is limited to 255 characters.
- To protect against pasting, combine validation with sheet protection (Protecting sheets and workbooks).
Finding and copying validation
- Home › Find & Select › Data Validation selects every validated cell on the sheet.
- To copy just the rule, copy a cell and use Paste Special › Validation.
- To remove rules, select cells, open Data Validation and click Clear All.
- Tick Apply these changes to all other cells with the same settings when editing a rule to update every copy at once.
Check yourself
1. Which validation type creates a drop-down?
Allow: List with In-cell dropdown ticked shows an arrow.
2. Why point a drop-down to a name that refers to a table column?
Tables expand, and the name refers to the whole column of the table.
3. In a dependent list, the source is =INDIRECT(A2). What must exist?
INDIRECT converts the category text into a reference to the matching name.
4. Which alert style lets the user keep an invalid value after a warning?
Warning asks whether to continue; Stop never accepts invalid input.
5. A user pastes text into a cell that only allows whole numbers. What happens?
Pasting overwrites validation. Use Circle Invalid Data or protection to guard against it.