Sub topic 5
Restricting the Selector with a Data Validation Dropdown
This chapter builds the dropdown that controls the scenario switch. It assumes you can write basic formulas, you know the difference between $A$1 and A1, and you have the assumptions laid out with one block per scenario. It also assumes you have met CHOOSE in the previous chapter.
By the end you will be able to create a list-type validation rule on the selector cell. You will also know where a dropdown stops protecting you and how to close those gaps.
Why the selector needs restricting
The selector is one cell that decides which scenario the whole model shows. Everything downstream depends on it. If someone types "upside" with a trailing space, or "Optimistic", the lookup that converts the name to a number fails. The error then spreads through every formula that depends on it.
Free text in a driver cell is a common source of model errors. A dropdown removes that class of error at the point of entry. The user picks from a fixed list, so the entry is always a name the model knows.
Data validation is the spreadsheet feature that does this. A validation rule is attached to a cell or range. It checks what is entered and either accepts it, warns, or rejects it.
Setting up the list source
The dropdown needs a list of allowed values stored in cells. Keep this list on the assumptions sheet, next to the scenario blocks, and label it clearly. In this chapter the three names sit in B5:B7.
| Cell | Value |
|---|---|
| B5 | Base |
| B6 | Upside |
| B7 | Downside |
The selector sits in C3. The order of the list matters later, because the next chapter turns the selected name into its position in this list. Position 1 is Base, 2 is Upside and 3 is Downside. That same order must match the column order of the assumption blocks that CHOOSE reads.
Storing the names in cells, rather than typing them into the rule, means there is one place to edit a scenario name. It also lets formulas refer to the same list.
Creating the dropdown
Follow these steps in Excel. Google Sheets has the same feature under Data, then Data validation, and the settings are equivalent.
- Select the selector cell
C3. - Open Data, then Data Validation.
- On the Settings tab, set Allow to List.
- In Source, enter the range reference.
- Make sure In-cell dropdown is ticked.
- Click OK.
The rule can be written like this:
Data validation (Allow: List)
Source: =$B$5:$B$7
B5: Base
B6: Upside
B7: DownsideThe source uses absolute references. This is not strictly required for a rule on a single cell. It does protect you if the rule is later copied to other cells, because a relative source would shift and point at the wrong range.
After this, C3 shows an arrow when selected. Clicking it lists Base, Upside and Downside.
Source options and their trade-offs
There are three ways to supply the list. Each has a cost.
| Source type | Example | Strength | Weakness |
|---|---|---|---|
| Typed list | `Base,Upside,Downside` | Quick to set up | Names live in the rule, so a rename needs the rule edited and the list cells do not match |
| Range reference | `=$B$5:$B$7` | One place to edit names | Source must be on the same sheet in older Excel versions |
| Named range | `=ScenarioList` | Readable and works across sheets | Needs a name to be defined first |
A typed list creates two copies of the truth. If you later rename "Downside" to "Stress" in the cells but not in the rule, the dropdown still offers "Downside", and MATCH fails. For a model that others will maintain, use a range reference or a named range.
Named ranges are covered in a later chapter. For now, the range reference is enough.
The error alert
The error alert tab controls what happens when a user types something that is not in the list. It has three styles.
- Stop rejects the entry. The user must retry or cancel. This is the right choice for a scenario selector.
- Warning explains the problem but lets the user choose to keep the entry anyway.
- Information only notifies the user. The invalid entry stays.
The default style is Stop, but check it. It is easy to change it by accident, and "Show error alert after invalid data is entered" must be ticked. If that box is unticked, the rule only builds the dropdown and allows anything typed.
Write a useful message in the alert. Compare these two.
- Poor: "This value doesn't match the restrictions defined for this cell."
- Better: "Choose Base, Upside or Downside from the list."
The Input Message tab shows a small note when the cell is selected. Use it for a short instruction such as "Select the scenario to run." Keep it brief, since it appears every time someone clicks the cell.
Case and spacing behaviour
Validation against a list typed from a range is case-sensitive in some situations. When the source is a range reference, Excel treats a typed entry as valid only if it matches the case of an item in the list. When the source is a typed comma list, the check is case-sensitive too. Behaviour differs between Excel versions and Google Sheets, so test it in your own application rather than relying on memory.
Trailing spaces are the other common issue. A value such as "Base " does not match "Base". The dropdown prevents this when the user picks from the list, because the selected text is copied exactly from the source cell. The risk appears when the list cells themselves contain stray spaces. Then the selector inherits them, and anything that compares text to a hard-coded string will fail. Keep list cells clean.
Where validation does not protect you
A dropdown is a guard on entry, not a lock on the cell. Three situations bypass it.
- Pasting. Pasting a value into
C3from another cell replaces the validation rule, or skips the check, depending on the paste mode. A normal paste copies the source cell's validation settings over the target. A value pasted from a cell with no rule leavesC3with no rule at all. - Clearing contents. Pressing Delete empties the cell and Excel accepts it. A blank selector then makes MATCH return
#N/A. - Changing the list. If someone deletes or edits
B5:B7after the selector was set, the selector may hold a value that is no longer in the list. Excel does not recheck existing values.
You can find existing invalid entries with Data, then Data Validation, then Circle Invalid Data. This draws red circles around cells that break their rules. It helps when you inherit a model.
To catch the problems that validation cannot prevent, add a check cell. The selector check below confirms that the name is on the list:
=IF(ISNUMBER(MATCH($C$3, $B$5:$B$7, 0)), 0, 1)It returns 0 when the name is found and 1 otherwise. A later chapter feeds checks like this into a master check.
Protecting the rule
If other people use the model, consider locking every cell except the selector and the inputs. Lock cells through Format Cells, then Protection, and switch on sheet protection under Review. Leave C3 unlocked so users can change it. Sheet protection stops accidental edits to formulas and to the validation rule itself. It is not a security feature, so do not treat it as one.
Formatting the selector so it is visible
A selector that looks like any other cell gets missed. Give it the same input style you use for other hard-coded inputs, such as blue font and a pale yellow fill, and put a clear label beside it. Place it at the top of the assumptions sheet, or on a summary sheet if the model has one. Some modelers also repeat the selected scenario name in the header of each output sheet, using a formula like =Assumptions!$C$3, so a printed page always shows which case it came from.
A full walkthrough
Suppose you have an assumptions sheet with the scenario list in B5:B7, the selector label in B3 and the selector in C3.
- Type "Scenario selected" in
B3. - Type the three names in
B5:B7. - Select
C3and open Data Validation. - Choose List and enter
=$B$5:$B$7. - On Error Alert, choose Stop and enter the message "Choose Base, Upside or Downside from the list."
- Click OK and choose Upside in the dropdown.
- Try typing "Optimistic" into
C3. Excel should reject it with your message. - Try typing "Base " with a trailing space. Excel should reject this too.
- Select
C3, press Delete, and notice that Excel accepts the blank. This is the gap the check cell covers.
After step 9, set C3 back to Base before moving on.
Common mistakes
- Leaving the error alert on Information. The dropdown appears but invalid entries stay.
- Using a typed list while also keeping names in cells. The two copies drift apart after a rename.
- A relative source reference. Copying the rule moves the range and the dropdown lists the wrong cells.
- List order that differs from the assumption columns. The dropdown works, but CHOOSE returns the wrong scenario's numbers. Always check that position 1 in the list is the first column in each block.
- Trusting the dropdown alone. Pasting and clearing bypass it, so add a check.
Summary
A list-type data validation rule on the selector cell limits entries to the scenario names stored in B5:B7. A range or named range source keeps the names in one place. The Stop alert style rejects invalid typing, and a short, specific message tells the user what to do. Validation does not cover pasting, clearing or later edits to the list, so a check cell is still needed. The next chapter takes the selected name and converts it to a number with MATCH.
Exercise
A colleague set up a dropdown on the selector cell with a typed source, Base,Upside,Downside, and the error alert style set to Warning. Name two problems this creates and give a fix for each.
Show answer
First, the Warning style lets a user keep an invalid entry, so a name such as "Optimistic" can sit in the selector and make MATCH return #N/A. Change the alert style to Stop. Second, the typed source stores the names inside the rule while the model also keeps them in cells, so renaming a scenario in the cells leaves the dropdown offering the old name. Change the source to the range =$B$5:$B$7 or to a named range so there is one list to maintain.
Exercise
The selector is C3 and the list is B5:B7. Write a formula that returns 0 when the selector holds a name from the list and 1 otherwise. Explain why you still need it when the cell already has a dropdown.
Show answer
=IF(ISNUMBER(MATCH($C$3, $B$5:$B$7, 0)), 0, 1). The dropdown only checks values entered by typing or selecting. Pasting a value over the cell, pressing Delete, or editing the list afterwards can leave an invalid selector without any alert. The formula detects those cases, and a master check can then flag them.