|
Home > Validation > Dependent > Advanced Advanced Dependent Drop-Down Lists
|

Maybe you know how to set up a simple Dependent Drop Down List, but now you need something fancier, such as:
For those situations, I recommend using the Dependent Lists with Tables technique. It's easy to set up and maintain, and can support multi-level dependent drop-down lists.

With this dependent drop down technique, from AlexJ, you can see a full list of customers in a drop down list. Or switch to a short list, with just your top customers. The technique is driven by a formula -- no macros required.
This short video shows the steps, and there are written steps below the video.
The first step is to create two named lists -- they will be used as the source for the drop-down lists.

Next, you will create the drop-down list, by using data validation with an IF formula:

Select the cell with the data validation list and click the drop-down arrow.


This is another example of dependent drop-down lists in Excel, with the IF function used with INDIRECT, for a more flexible drop down. In this example:

This video shows the basic set up steps, and then shows how to use the Excel IF function with a dependent drop down. There are written steps below the video, and you can download the sample file below.
In this example, there’s a drop down to select a country in column A. If you select USA as the country, cities from the USA appear in the dependent drop down in Column B.

There are city lists in the workbook, and each list is named to match its country name.

Originally, there was a simple formula for the data validation list in column B:
=INDIRECT(A2)

So, if you selected USA in cell A2, dependent drop-down list shows cities from the range named USA.

With that simple INDIRECT formula, the drop-down list in column B does NOT work, if no country is selected in column A.

Instead of a drop-down arrow that does not work, we will change the dependent drop down formula, and add the IF function. The revised formula will give users the option to select a World city, if they have not selected a country in column A.
On the Lists worksheet, there is another range, named World, highlighted in the screen shot below.

Just as you can use the IF function on the worksheet, you can use it in a data validation formula.
For the dependent drop-down cells in column B, we’ll change the formula to the following:
After this change to the data validation formula, if you click on a drop down arrow in column B, and no country is selected in column A, the list of world cities appears.

Here is what the revised formula does:

After someone selects an item from a dependent drop down, they could go back to the main drop down, and select a different item. That could result in mismatched items in that row.
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, try one of the following techniques:
To block changes to the first list, you can change the data validation formula, so the list does not appear unless the second cell is empty. This video shows you how this technique works, and written instructions are below the video.
With dependent drop down lists, problems can occur, if someone goes back to the first list, and changes it. Then, the first and second selections are mismatched.
For example, in the screen shot below, Fruit is the first choice, and Banana is selected in the second column.
You don't want someone to go back to the first drop down, and choose Vegetable!

To block changes to the first list, you can change the data validation formula, so the list does not 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.
To change the formula, follow these steps:
=IF(C2="", Produce, INDIRECT("FakeRange"))
Now, the drop down in the first column (Produce Type) will not work, if the Item has been selected in that row.

In the previous section, the data validation formula was designed to prevent selections from the first drop down, if the cell to the right contained data.
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.

When you select a Region, event code clears the cell to the right. To add the code, right-click the sheet tab, and click View Code.
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. |
Private Sub Worksheet_Change _(ByVal Target As Range) On Error Resume Next If Target.Column = 2 Then If Target.Validation.Type = 3 Then Application.EnableEvents = False Target.Offset(0, 1).ClearContents End If End If exitHandler: Application.EnableEvents = True Exit Sub End Sub
Because the INDIRECT function only works with references, not formulas, the usual method for dependent data validation will not work with lists that use formula-based dynamic named ranges, such as OFFSET ranges.
Instead, use one of the following solutions when a dynamic list is required:
To avoid the problem, use named Excel tables, instead of formula-based dynamic ranges.
Then, use the INDIRECT function, as usual, to create a dependent drop-down list.
If you can't use Named Excel Tables, use the following method to create dependent lists from formula-based dynamic named ranges,



Next, follow the steps below, to create and name the dependent item lists:

Next, to name the column in which each list is located, follow these steps:
Finally, to create the dependent drop down on the data entry sheet, follow the steps below:

Note: The SUBSTITUTE function removes the spaces in multi-word category items, such as "Other Stuff", so they'll match the one-word First Cell names and Column names
Don't miss my monthly Excel newsletter! You'll get quick tips, article links, and a bit of fun. Add your email, and click Sign Up.
Next, when you get my reply, click the Confirm button. I add this step to protect you from spam!
Dependent Drop Down Setup Choices
Dependent Drop Down from Dynamic Arrays
Dependent Drop Downs from a Sorted List
Last updated: January 17, 2025 10:43 AM