04 · Data Validation Advanced & Form Controls¶
Level 1 covered basic dropdown lists. This module covers dependent (cascading) dropdowns, custom validation formulas, and interactive Form Controls (option buttons, checkboxes, combo boxes) that let a sheet respond to user clicks without VBA.
1. Worked dataset¶
Build this table on a sheet named Catalog, A1:B7:
| A | B | |
|---|---|---|
| 1 | Category | Item |
| 2 | Fruit | Apple |
| 3 | Fruit | Banana |
| 4 | Fruit | Cherry |
| 5 | Veg | Carrot |
| 6 | Veg | Potato |
| 7 | Veg | Onion |
2. Named ranges for dependent dropdowns¶
- Build two named lists: select
B2:B4(Apple, Banana, Cherry) and name itFruit(Formulas → Define Name). SelectB5:B7(Carrot, Potato, Onion) and name itVeg. - Type
FruitinD1andVeginE1as the two category labels the first dropdown will offer. - In
G1, set Data Validation → List → Source=D1:E1(Fruit, Veg). This is the first dropdown. - In
G2, set Data Validation → List → Source=INDIRECT(G1).INDIRECTturns the text"Fruit"selected inG1into a reference to the named rangeFruit, soG2's list changes to Apple/Banana/Cherry whenG1="Fruit", and to Carrot/Potato/Onion whenG1="Veg". This is the standard cascading-dropdown pattern. - Manual check: set
G1toVeg.INDIRECT("Veg")resolves to the named rangeVeg=B5:B7= Carrot, Potato, Onion — theG2dropdown should offer exactly those three, not the fruits.
3. Custom validation formulas¶
- Select
H2, Data Validation → Custom, Formula:=AND(H2>0,H2<=100)This restricts entry to numbers strictly between 0 and 100 inclusive of 100 — typing150or0is rejected,100is accepted. Trace by hand:H2=100→AND(100>0,100<=100)→AND(TRUE,TRUE)→TRUE, allowed.H2=0→AND(FALSE,TRUE)→FALSE, rejected. - Select
I2, Data Validation → Custom, Formula:=COUNTIF($I$2:$I$10,I2)=1This blocks duplicate entries anywhere inI2:I10— if the value being typed already appears once elsewhere in the range, the count becomes2and the formula returnsFALSE, rejecting the entry.
4. Form Controls — Combo Box and Check Box¶
- Enable the Developer tab (File → Options → Customize Ribbon → check Developer).
- Developer → Insert → Form Controls → Combo Box. Draw it near
K1. Right-click → Format Control → Input rangeB2:B7, Cell linkK2. Selecting an item in the combo box now writes that item's position number (1–6) intoK2, not the text itself — this is the key gotcha with Form Control combo boxes. - In
K3, retrieve the actual text:=INDEX(B2:B7,K2). If the combo box shows "Potato" selected (the 5th item inB2:B7),K2holds5andK3becomes=INDEX(B2:B7,5)=Potato. Confirm by counting: Apple(1), Banana(2), Cherry(3), Carrot(4), Potato(5), Onion(6) — position 5 is indeed Potato. - Developer → Insert → Form Controls → Check Box. Right-click →
Format Control → Cell link
L1. Checking the box writesTRUEtoL1, unchecking writesFALSE— use=IF(L1,"Included","Excluded")inL2to turn that boolean into a readable label.
Cheat sheet¶
| Task | How |
|---|---|
| List validation | Data Validation → List → Source range or comma list |
| Cascading dropdown | Named ranges per category + =INDIRECT(cell) as Source |
| Custom rule | Data Validation → Custom → formula returning TRUE/FALSE |
| No duplicates | =COUNTIF($range,cell)=1 as Custom formula |
| Combo Box (Form Control) | Input range + Cell link (returns position number) |
| Position → text | =INDEX(range,cell_link) |
How It Actually Works¶
Dependent dropdowns (where a second list's options change based on a first
selection) and form controls both work by exploiting the same
recalculation-and-lookup machinery you already know, wired together rather
than by any special "cascading dropdown" feature. A dependent dropdown's
validation formula typically uses INDIRECT or a dynamic named range built
from the first cell's value — INDIRECT takes a text string and resolves
it to an actual range reference at calculation time, which is powerful (the
same formula can point at completely different ranges depending on other
cell values) but comes at a real cost: INDIRECT results are opaque to
Excel's dependency graph, since the engine can't know in advance which
range a piece of text will resolve to, so cells using it are treated as
volatile and get re-evaluated on every recalculation cycle regardless
of whether their actual inputs changed. Form controls like Option Buttons
and Combo Boxes (from the Developer tab) are different again — they aren't
formulas at all but embedded ActiveX/Form objects that write a value
directly into a linked cell on user interaction, which is what then feeds
your dependency-graph formulas downstream.
Exercise¶
Build the cascading dropdown in Section 2, then set G1 to Fruit
and confirm G2 only offers Apple/Banana/Cherry. Add a custom
validation rule on a new cell M2 that only accepts even numbers:
=MOD(M2,2)=0 — verify by hand that 4 is accepted (MOD(4,2)=0)
and 7 is rejected (MOD(7,2)=1).