Sub topic 3
Drive a Drop-down from a Cell Range
This chapter shows how to build a drop-down whose options come from cells in a spreadsheet instead of a typed list. It covers ranges on the same sheet and on another sheet, how the list updates, and the errors that most often break it.
Prerequisites assumed: you can select cells and ranges, you know the difference between A2 and $A$2, and you can refer to another sheet in a formula (for example Lists!A2:A). You should also know how to open the data validation dialog, which an earlier chapter covered.
Why use a range instead of typed items
A typed list is stored inside the validation rule. To change an option, you must open the rule and edit it. If the same list is used in several places, you must edit every rule.
A range-based list stores the options in cells. The rule only points at those cells. When you edit a cell in the source range, every drop-down that uses it shows the new option.
| Point | Typed list | Range-based list |
|---|---|---|
| Where the options live | Inside the rule | In cells |
| Changing an option | Edit each rule | Edit one cell |
| Option text can contain commas | No, commas separate items | Yes |
| Can be built by a formula | No | Yes |
| Best for | Short, fixed lists such as Yes/No | Lists that change or are shared |
A range-based list is the better choice when the list has more than a handful of items, when more than one column uses it, or when someone other than you maintains it.
Build one step by step
This example uses a task tracker. Column C holds a status. The allowed statuses live on a separate sheet named Lists.
- Add a sheet and name it
Lists. - In
Lists!A1, type the headerStatus. InA2:A4, typeNot started,In progressandDone. - Go back to the tracker sheet and select
C2:C100. - Choose Data > Data validation, then Add rule.
- Under Criteria, choose Dropdown (from a range).
- Click the grid icon in the range box and select
Lists!A2:A4. You can also type the reference. - Leave the invalid-input setting on Reject input for now. The next chapter covers the alternative.
- Click Done.
Each cell in C2:C100 now shows an arrow. Clicking it lists the three statuses. Typing a value that is not in the list is rejected.
Referring to the range
The range you give the rule is a normal reference. A few forms matter.
Lists!A2:A4points at exactly three cells. Adding a fourth status inA5does not change the drop-down.Lists!A2:Ais an open-ended range that runs to the bottom of the column. A new item inA5appears in the drop-down. This is the form to use for lists that grow.Lists!A2:A20reserves space for growth but is limited to row 20.
Blank cells inside the range are not shown as options. That is why an open-ended range works well: the empty rows below your list do not appear.
Items are shown in the order they appear in the range, from top to bottom. To control the order of the drop-down, sort the source cells.
A range-based rule uses a single row or a single column. If you select a block of several columns, the rule is not accepted as a list source. Point it at one column, or at one row.
Same sheet and other sheets
The source range can sit on the same sheet as the drop-down. This is convenient for small lists, but the list takes up space in the layout, and users may type over it by mistake.
A separate sheet is usually cleaner:
- You can protect the sheet or the range so only maintainers can edit it.
- You can hide the sheet if users do not need to see it. Hidden sheets still feed the rule.
- You can keep several lists side by side, one per column, each with its own header.
You can also point at a range in a different spreadsheet file, but not directly. The data validation dialog does not accept an IMPORTRANGE call as its range. The usual workaround is to bring the values into your own file with IMPORTRANGE in a helper sheet, then point the rule at that helper range.
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/FILE_ID", "Lists!A2:A")Put this formula in Lists!E2, allow access when Sheets asks, and use Lists!E2:E as the source range.
Use a named range
A named range gives a range a readable name, which you can use in the rule. Select Lists!A2:A, choose Data > Named ranges, and name it StatusList. You can then type =StatusList in the range box of the validation rule.
This has two benefits. The rule is easier to read when you return to it months later. If you move the list, you change the named range in one place and the rules follow.
Make the list build itself with a formula
The source range can contain formulas. This lets the list update from other data. Two common patterns:
A unique list from a data column. If Data!B2:B holds repeated values, such as the names of regions, this formula lists each region once:
=SORT(UNIQUE(Data!B2:B))Put it in Lists!A2. The results spill into cells below it. Point the drop-down at Lists!A2:A. When a new region appears in the data, it appears in the drop-down.
A filtered list. The formula =FILTER(Lists!B2:B, Lists!A2:A=A2) returns only the items that belong to the category chosen in A2. A drop-down that points at the cells holding these results shows a different set of options for each category. The later chapter on dependent drop-downs builds this out fully.
A spilled result can also contain blank strings. Wrap the formula in FILTER(..., ... <> "") if empty-looking options appear in the drop-down.
How the list and the value interact
Sheets compares what is typed or chosen against the cell contents of the source range. Some consequences:
- Text is compared as text.
Doneanddoneare treated as a match, so typed input is accepted regardless of capitalization. The cell keeps what was typed, so you can end up with mixed capitalization in the column. Choosing from the drop-down avoids this. - Numbers and dates work too. If the source cells contain numbers, the drop-down shows them, and the chosen value is stored as a number.
- Extra spaces count. A source cell containing
Donewith a trailing space is a different value fromDone. When the source is typed by hand, trailing spaces cause hard-to-find mismatches. UseTRIMin a formula-built source to remove them. - Changing a source value does not rewrite existing cells. If you rename
In progresstoWorkingin the source, cells that already holdIn progresskeep that text. They no longer match the list, so they are flagged as invalid. Update them with find and replace.
Show the right number of options
A long list is hard to scan. Options for keeping it usable:
- Sort the source alphabetically, or by how often each option is used, with the common ones first.
- Type in the cell to narrow the list. Typing starts a filter, and matching items show up as you type.
- Split a long list in two with a dependent drop-down.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| The rule shows "Invalid range" or will not save | The range covers several columns and rows, or the sheet name is misspelled | Select one column or one row. Check sheet names, and quote names that contain spaces, for example `'Task Lists'!A2:A` |
| The drop-down is empty | The source cells are all blank, or a spilled formula has a `#REF!` error | Check the source cells and clear the spill area |
| A new item does not appear | The range ends before the new row, for example `A2:A4` | Use an open-ended range like `A2:A` |
| A blank option appears | The source contains a cell with an empty string from a formula | Filter out empty strings in the formula |
| Existing entries show a red warning mark | The source item was renamed or removed after the cell was filled | Update the cells to match, or restore the source item |
| The rule refers to the wrong cells after sorting | The source range was sorted along with other data | Keep source lists on their own sheet and sort only that column |
| Pointing at another file fails | The range box does not take `IMPORTRANGE` | Import into a helper sheet and point at that range |
A rule that refers to another sheet by name breaks if someone renames the sheet. Sheets normally updates references when a sheet is renamed, but a rule typed from a stale copy of the name can fail. Using a named range avoids this problem.
Rows and columns inserted in the source
If you insert a row in the middle of the source range, the range expands to include it. If you insert a row just below the last row of a fixed range such as A2:A4, the range does not expand, so the new item is missing. An open-ended range such as A2:A avoids this.
Deleting the source cells outright does more damage. The rule can point at nothing, and the drop-down stops working. Clear the contents of source cells instead of deleting rows when you only want to remove an option.
Test your work
After you build a range-based drop-down, check these cases:
- Open the drop-down and confirm all expected options appear and no blanks do.
- Add an item to the bottom of the source and check it appears.
- Type an invalid value and confirm it is rejected.
- Copy a filled cell and paste it into another cell in the validated range, and note what happens. The chapter on the limits of validation explains why pasting can behave differently.
Exercise
A drop-down in C2:C100 uses the source Lists!A2:A4. You add a fourth status in Lists!A5, but it does not show in the drop-down. What are two ways to fix this, and which is better for a list that keeps growing?
Show answer
First, edit the rule so the range is Lists!A2:A5. Second, edit the rule so the range is open-ended, Lists!A2:A. The open-ended range is better for a growing list, because every item added below the last one appears without editing the rule again.
Exercise
You rename the status In progress to Working in the source range. Cells in column C that already say In progress now show a warning mark. Why does this happen, and how do you fix it?
Show answer
Renaming the source cell does not change the text already stored in column C. That text no longer matches any item in the list, so Sheets flags it as invalid. Fix it by using find and replace to change In progress to Working in column C.
Exercise
Which formula placed in Lists!A2 builds a sorted drop-down source that shows each value in Data!B2:B once?
Show answer
=SORT(UNIQUE(Data!B2:B)). Point the drop-down at Lists!A2:A, and keep the cells below A2 empty so the result can spill.