How To Make Excel Data Validation Dependent Lists PDF
How To Make Excel Data Validation Dependent Lists PDF
html)
NOTE: There are other techniques for setting up dependent drop down lists, so choose the setup method that
is best for your needs (exceldependentdropdownsetup.html).
Fruit is selected as Produce Type in row 3, so the drop down shows the Fruit list
Vegetable is selected as Produce Type in row 4, so the drop down shows the Vegetable list
NOTE: There are other techniques for setting up dependent drop down lists, so choose the setup method that
is best for your needs (exceldependentdropdownsetup.html).
In the screen shot below, you can see the completed data entry sheet. Select a produce type (fruit or vegetable)
in column B. Then, in column C, a dependent drop down list show items for the selected product type only.
There are a few steps for setting up the drop down lists, and the details are in the sections below.
Create Lists
Next, you'll create lists with items for the drop down lists.
In this example, you'll set up 3 lists. The main list has produce types, and the other two lists have items for the
dependent drop downs.
NOTE: The Produce list has one-word items in it -- Fruit and Vegetable. This is important, because those
words will be used as Excel names, and two-word names are not allowed as names. If you need to use
multiple-word items in the main list, see: Using Two Word Items
Add the Dependent Lists
Next, type the dependent lists, with the headings Fruit List (in cell D2) and Vegetable List (in cell F2). These lists
can contain one-word items (apple), or multiple-word items (green beans).
1. Select a cell in the list, and on the Home tab, click Format as Table
2. Click on one of the Table Styles
3. Add a check mark for My table has headers
4. Click OK
Here is the Lists sheet, with all 3 lists formatted as Excel Tables
a. On the DataEntry sheet, type the headings in B2:C2 -- ProductType and Item
b. Select cell B2, and and on the Home tab, click Format as Table
c. Click on one of the Table Styles
d. Add a check mark for My table has headers
e. Click OK
Add the Main Drop Down
Next, you'll the main drop down list, in the Produce Type column
Note: If cell B3 is empty, you'll see the message shown below. Click Yes to continue.
3. Then, press the Tab key, to start a new row in the data entry table.
4. In the Produce Type column, select Vegetable from the Produce drop down list.
5. Move to the Item column, in the same row.
6. In the Item column, click the drop down arrow, and select an item from the Vegetable list
NOTE: If a Produce Type has not been selected, the Item drop down in that row will not work.
This video shows the basic set up steps, and then shows how to use the Excel IF function with a dependent drop
down.
1. Create the first named range and dropdown list as described above.
2. Create the supporting named lists, using one-word names, e.g. RedFruit, GreenFruit, YellowFruit
3. For the second dropdown, choose to Allow: List, and use a formula that removes the spaces from the names.
For example:
=INDIRECT(SUBSTITUTE(A2," ",""))
For example, your choices are 'Red Fruit', 'Green Fruit' and 'Yellow & Orange Fruit'. For the dependent lists, you
can create ranges with one-word names, such as YOFruit. Then, create a lookup table, which lists each item in
the first Excel data validation drop-down list, and the range where its dependent items will be stored.
To start, create the item lists and the first Excel data validation drop-down:
1. Create the first named range and drop-down list as described above. In this example, the range is named
ProductList, with values in cells A6:A8. The drop-down list in cell A2 uses ProductList as its source.
2. Create the dependent lists, and name them, using one-word names, with "List" at the end, e.g.
RedFruitList, GreenFruitList, YOFruitList. In this example, RedFruitList is in A11:A12,
YOFruitList is in A15:A16 and GreenFruitList is in A19:20.
3. Select an item from the drop-down list in cell A2.
Next, you'll create the lookup table, to match each item with its dependent items' range name.
1. In the column to the right of the FruitList range, enter the code name for each item's dependent list. For
example, YOFruit is entered as the code name for Yellow & Orange Fruit.
2. Name the lookup table. In this example, the range A6:B8 is named ProductLookup.
3. Select cell B2, and from the Data menu, choose Validation.
4. Choose to Allow: List.
5. For the Source, enter a formula that uses a VLookup formula to find the dependent list's range name -- a
combination of the code name and "List".
For example: =INDIRECT(VLOOKUP(A2,ProductLookup,2,0)&"List")
With Red Fruit selected in cell A2, the VLookup formula will return RedFruitList as the range name for the
dependent list. The RedFruitList items will be displayed in cell B2's drop-down.
To create a 3rd dependent drop down list, use the same techniques, to create lookup tables and items lists.
In the screen shot below, there are lookup tables named RedFruitLookup, YOFruitLookup and
GreenFruitLookup. Items lists, with the code names and "List", have been added to the worksheet.
In the data validation window, use this formula for the 3rd drop down:
=INDIRECT(VLOOKUP(B2,INDIRECT(VLOOKUP(A2,ProductLookup,2,0)&"Lookup"),2,0)&"List")
The formula finds the lookup table based on the product type selected in cell A2, e.g. RedFruitLook, and gets the
code for the selected product -- Mac. It adds "List" to the code, and shows the items in the MacList range.
Note that the region names are not unique -- there is a West region in both Canada and the USA -- so we
can't show a City list that is only based on the region names.
To make sure that the correct list of cities appears, the city lists will be named for the country and region. There
are 2 countries, and each country has 3 regions, so we will set up 6 named ranges for the 3rd level drop down
lists.
NOTE: If you need more than a few named ranges for your 3rd level lists, try the Dependent Lists with Tables
(https://www.contextures.com/exceldatavaldependindextables.html) technique instead -- it will be easier to set
up and maintain.
1. Create the main named ranges - Country, Canada and USA, as described above.
2. Create another set of named ranges, naming them for the available combinations in the first two lists. For
example, create ranges named CanadaWest and USAWest.
3. On the data entry sheet, set up drop down lists in the Country and Region columns.
4. For the City dropdown, add data validation, and choose to Allow: List
5. For the source, use a formula that combines the entries in the first two columns.
For example, in cell D2, the data validation formula uses INDIRECT and SUBSTITUTE, to combine the
values in B2 and C2, and remove any space characters:
=INDIRECT(SUBSTITUTE(B2&C2," ",""))
Use Dynamic Lists
Because the INDIRECT function only works with references, not formulas, the previous method for dependent
data validation won't work with lists that use formula-based dynamic named ranges
(https://www.contextures.com/xlNames01.html#Dynamic), such as OFFSET ranges. Use one of the following
solutions when a dynamic list is required:
Then, use one of the INDIRECT function examples shown above, to create a dependent drop down list.
1. Create the first named range and dropdown list as described above.
2. Create the supporting named lists, and name the first cell in each range, e.g. cell B1 is named Fruit and cell
C1 is named Vegetables.
3. Name the column in which each list is located, e.g. column B is named FruitCol and column C is named
VegetablesCol
4. For the second dropdown, choose to Allow: List, and use a formula that calculates the lookup range. For
example, if the first dropdown list is in cell E2:
=OFFSET(INDIRECT($E2),0,0,COUNTA(INDIRECT(E2&"Col")),1)
if two-word items will be used, you can include the SUBSTITUTE function in the formula:
=OFFSET(INDIRECT(SUBSTITUTE($F2," ","")),0,0,COUNTA(INDIRECT(SUBSTITUTE($F2,"
","")&"Col")),1)
For example, Fruit could be selected from the main drop down, and then Lemon in the dependent drop down. If
Fruit is changed to Vegetable later, the Lemon selection would be incorrect -- it's not a vegetable.
To prevent invalid selections, here are a couple of techniques that you can use
To block changes to the first list, you can change the data validation formula, so the list doesn't work unless the
second cell is empty.
Instead of just referring to the Produce range for the Produce Type drop down, the formula will check for an
entry in the Item column.
If the Item cell is blank, the Produce Type drop down will show the Produce list
If an item has been selected, the drop down will try to show the range created by the INDIRECT function --
"FakeRange". Because there is no range with that name, the result is an error, and the drop down will not
work.
5. Click OK
Now, the drop down in the first column won't work if the Item has been selected in that row.
Another option is to use a macro, to clear the dependent cell, after making a selecting in the first drop down. That
will prevent mismatched selections.
In this example, column B contains a drop down list of Regions. After you select a Region, the drop down list in
column C shows the customers in the selected region.
Go back and select a different region, and the existing customer name will be cleared.
Paste the following code onto the sheet module. You might need to change the column number, to match the
column number on your worksheet.
NOTE: The sample workbook also has code for clearing multiple dependent cells.
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
(https://www.contextures.com/signup01)
More Tutorials
Data Validation Basics (xlDataVal01.html)
More Tutorials
Data Validation Basics (xlDataVal01.html)
(https://www.contextures.com/datavalidationmultiselectpremium.html)
(https://www.contextures.com/signup01)
(https://www.contextures.com/exceltoolsaddin.html)
(https://www.contextures.com/datavalidationmultiselectpremium.html)
(https://www.contextures.com/datavalidationmultiselectpremium.html)
(https://www.contextures.com/datavalidationmultiselectpremium.html)
(https://www.contextures.com/datavalidationmultiselectpremium.html)
(https://mvp.microsoft.com/en-us/mvp/Debra%20%20Dalgleish-7612)Debra Dalgleish
(https://mvp.microsoft.com/en-us/mvp/Debra%20%20Dalgleish-7612)