How to Create a Dependent Drop Down List in Excel
-
— By
Sumit Bansal
Watch Video – Creating a Dependent Drop Down List in Excel
An Excel drop down list is a useful feature when you’re creating data entry forms or Excel Dashboards.
It shows a list of items as a drop down in a cell, and the user can make a selection from the drop down. This could be useful when you have a list of names, products, or regions that you often need to enter in a set of cells.
Below is an example of an Excel drop down list:
In the above example, I have used the items in A2:A6 to create a drop-down in C3.
Read: Here is a detailed guide on how to create an Excel Drop Down List.
Sometimes, however, you may want to use more than one drop-down list in Excel such that the items available in a second drop-down list are dependent on the selection made in the first drop-down list.
These are called dependent drop-down lists in Excel.
Below is an example of what I mean by a dependent drop-down list in Excel:
You can see that the options in Drop Down 2 depend on the selection made in Drop Down 1. If I select ‘Fruits’ in Drop Down 1, I am shown the fruit names, but if I select Vegetables in Drop Down 1, then I am shown the vegetable names in Drop Down 2.
This is called a conditional or dependent drop down list in Excel.
Here are the steps to create a dependent drop down list in Excel:
Now, when you make the selection in Drop Down 1, the options listed in Drop Down List 2 would automatically update.
Download the Example File
How does this work? – The conditional drop down list (in cell E3) refers to =INDIRECT(D3). This means that when you select ‘Fruits’ in cell D3, the drop down list in E3 refers to the named range ‘Fruits’ (through the INDIRECT function) and hence lists all the items in that category.
Important Note: If the main category is more than one word (for example, ‘Seasonal Fruits’ instead of ‘Fruits’), then you need to use the formula =INDIRECT(SUBSTITUTE(D3,” “,”_”)), instead of the simple INDIRECT function shown above.
- The reason for this is that Excel does not allow spaces in named ranges. So when you create a named range using more than one word, Excel automatically inserts an underscore in between words. For example, when you create a named range with ‘Seasonal Fruits’, it will be named Season_Fruits in the backend. Using the SUBSTITUTE function within the INDIRECT function makes sure that spaces are converted into underscores.
Reset/Clear Contents of Dependent Drop Down List Automatically
When you have made the selection and then you change the parent drop down, the dependent drop down list would not change and would, therefore, be a wrong entry.
For example, if you select the ‘Fruits’ as the category and then select Apple as the item, and then go back and change the category to ‘Vegetables’, the dependent drop down would continue to show Apple as the item.
You can use VBA to make sure the contents of the dependent drop down list resets whenever the main drop down list is changed.
Here is the VBA code to clear the contents of a dependent drop down list:
Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next If Target.Column = 4 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
The credit for this code goes to this tutorial by Debra on clearing dependent drop down lists in Excel when the selection is changed.
Here is how to make this code work:
Now, whenever you change the main drop down list, the VBA code would be fired and it would clear the content of the dependent drop down list (as shown below).
Download the Example File
If you’re not a fan of VBA, you can also use a simple conditional formatting trick that will highlight the cell whenever there is a mismatch. This can help you visually see and correct the mismatch (as shown below).
Here are the steps t0 highlight mismatches in the dependent drop down lists:
The formula uses the VLOOKUP function to check whether the item in the dependent drop down list is the one from the main category or not. If it isn’t, the formula returns an error. This is used by the ISERROR function to return TRUE which tells conditional formatting to highlight the cell.
Download the Example File
You May Also Like the Following Excel Tutorials:
- Extract Data based on a drop-down list selection.
- Creating a drop-down list with search suggestions.
- Select multiple items from a drop-down list.
- Create multiple drop-down lists without repetition.
- Save Time with Data Entry Forms in Excel.
Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster
74 thoughts on “How to Create a Dependent Drop Down List in Excel”
-
Is it also possible to rewrite the formula to apply on whole column ? E.g. in column A I select Vegetable and in column B I will get a drop-down with valid vegetable values. If I change Vegetable value in A to Fruit I would get a drop-down for fruit.
The expanding the data validation pattern cell by cell in excel is not a solution for me as I’m generating the excel file and not creating it manually.
-
Thank you very much for the video!! what I am trying to do is when you select “India” all the names automatically go down in the column without you selecting one name if you select US all the names in the list will be copies in the column. How can i do it. I have 3 supervisors each have 14 team members under their name and they have to fill out a log. I don’t want them to click 14 times to get their team on the log. Can you please help me. thank you.
-
You should instead use the if command. Set each cell below to check if supervisor A is selected in that cell, then set the rest of the cells to fill a certain name. Each cell would be set to only one name per supervisor.
-
-
This is great, but I have a problem. My Column headers are 2 words and not a single word like “Fruit” or “Vegetable” but rather “Fruit and Vegetable” and “Grains and Breads.” I require a 2 word header value/name. The “named range” uses underscore (_) between each word, which is fine, but the secondary/dependent drop-down does not populate.
thanks for any tips or advice on a workaround of this nature.
-
Is it possible to put the data in another worksheet of the same excel and use the indirect function?
-
Doesn’t work. Says “The Source currently evaluates to an error.” anybody with a simpler way of doing this that actually works and doesn’t require someone to know VBA code?
-
Small formula correction for those looking to use a conditional color change as opposed to a VBA script to highlight mismatches.
The original formula: =ISERROR(VLOOKUP(E3,INDEX($A$2:$B$6,,MATCH(D3,$A$1:$B$1)),1,0))
Needs to have a “0” (zero) added to the MATCH function’s third argument. The updated formula is:
=ISERROR(VLOOKUP(E3,INDEX($A$2:$B$6,,MATCH(D3,$A$1:$B$1,0)),1,0))For MATCH, zero is an implied default, but some of you – like me – may have had formatting issues based on the original formula due to how it processes the range. This error – for me – was being caused by the MATCH function… so forcing a “0” in the third argument makes for an exact match. Otherwise, you have to sort your menu and that’s a pain.
To the author… excellent post and thank you!
-
I want to use 3 or more drop down lists but is showing error
Please help -
Two teammates and I have been unsuccessful in building a spreadsheet with one drop down list and two dependent drop down lists. We can create a drop down list of five “entities” in column one. We can create a dependent drop down list of “expense categories” in column two which only shows the relevant “expense categories” of the “entity” selected in column one. We can not figure out how to create a second dependent drop down list of “expense details” in column three which only shows the relevant “expense details” of the “expense category” selected in column two. Any help would be greatly apreciated! I would be willing to pay for assistance or make a donation to the favorite charity of anyone who could help.
-
This method seem not to be working anymore with the latest version of Excel and Windows. I am running version Office 365 MSO (16.0.12325.20328) on Windows 10 Pro version 1909.
This is extremely frustrating. I have been using this type of lists for years using indirect to “construct” range names, where the range name reference the list to be used.
Can someone please tell me why indirect lost the functionality to construct name ranges in data validation to create lists?
-
Hello Theron.. I am on Office 365 ProPlus and this method is working for me. I am using Version 1908. It’s possible that there could be an issue with a specific version. I have not heard anything about it but will search and see if I can find anything
-
Thank you Sumit,
If not for your comment I would not have done the above to the letter. It works now.
I can say why it did not worked initially. My name range was defined in the “Refer to:” section as =OFFSET(CatPr,0,0,COUNTA(Data!$L:$L)-2,1). This was to ensure we can add more items and not showing blank spaces. However, it seems that indirect does not like it when the name range has a formula in the “Refer to:” section. Which is silly, is it not?
Regardless, Thanks
-
Thank you so much for the clear instructive and useful information
-
-
-
What if we have a additional column of “Groceries” with “Vegetable” and “Fruit” ?..i am getting values of main column as Fru./Vege./Groc.. but in dependent column i am not getting values …what i am doing wrong ?
-
I have a 3 dependant drop down list (N dependant on M, M dependant on L). and for some reason my code below seem to work as such, hope it helps:
On Error Resume Next
If Target.Column = “$L” Then
If Target.Validation.Type = “$M” Then
Application.EnableEvents = False
Target.Offset(0, 1).ClearContents-
just realised that for some reason it affects other column not defined by my above codes. any idea how I can prevent that?
-
-
hi
First of all, this is one of the best tutorial! Thanks.I had a problem with your guidance. when I used your formula ” =INDIRECT(SUBSTITUTE(E5,” “,”_”)) ” Excel show me this error: (a named range you specified cannot be found)
Please change ” (E3,” “,”_”) ” to (E5,” ”,”_”).Maybe someone like me is enough lazy to just copy the formula!!!
Thank you very much. -
Works great, although when I open the dependent dropdown, it defaults to the last item on the list. Any way to make it default to the top?
-
shit
-
I have everything working correctly for the second drop down, until I get to the end and I hit OK then it tells me “the Source currently evaluates to an error. Do you want to continue?
Could this be because my first drop down has numbers? I don’t know why else it would not work ?! any help would be great!
-
Hi Danielle, it is due to the fact this this method is not supported anymore. I would like someone to comment why the use of the indirect function is not working anymore.
-
-
fff
-
The VBA code only works in your sample worksheet, if i shift the dropdown columns to the right and change the vba code accordingly it does not work. How can i get hte code to work?
-
I had a similar problem in that my drop down menus were in columns F and G rather than D and E. To get the VBA code to work, I changed the line “If Target.Column = 4 Then” to “If Target.Column = 6 Then”, since F is the sixth column. The second drop down menu would then clear. Hope this helps someone.
-
-
I want to use the VBA code, but I would need to add it to code already existing for the worksheet. How would you make this work?
-
Any thoughts how to select both fruits and vegies as multi select ( in A) followed by list of fruits and vegies in column B
-
Been looking for this as well. Any luck?
-
-
How about if fruits and vegetables have different number of items? Let’s say fruits has 5 items and vegetables has 3 items, if vegetables is selected then in drop down 2 has 2 blank items. Is there a way to eliminate those 2 blanks in drop down 2?
-
Use ctrl-select only the cells you wish to use. This allows you to omit any blank cells during the “Formulas -> Create from Selection” step.
-
I tried that. But it created an error: “This selection isn’t valid. Make sure the copy and paste areas don’t overlap unless they are the same size and shape.”
Any ideas, or sample file?-
Owh, never mind. Solved it by defining name for each selection. Thanks.
-
-
-
-
If i need to create named range (dependent) for cars depending on the brand but they don´t have a fixed number of cars. Does this mean I have to define the range manually per brand instead of “create for selection”? is there any way we could use remove the blank spaces automatically?
-
I’m getting an error “A named range ou specified cannot be found.”
-
How can i link this drop down to dashboard or chart? please help me
-
Very useful tutorial. Thanks
-
Thank you. It was pretty clear and useful.
-
Excellent content, thank you for your expertise and help!
-
Thanks mate – very helpful
-
Thank you sooo much.. very useful
-
Very Nicely explained and very useful. Thanks
-
Mine isn’t working. I followed the steps exactly, but my second row for lists shows an arrow for a dropdown list, but doesn’t actually create a dropdown list based on the choice made in the first column.
-
For clarification, when I attempt the second part of the Data Validation, I get an error message saying “The Source currently evaluates to an error.” But the first selection works just fine. Can someone please help me?
-
Hey Kyle this happen to me as well. You cannot have spaces anywhere you are making a drop down list. Your list may have been two words like yellow car. Instead you would have to put yellow_car. Put underscores for all of your spaces and it should work
-
Yeah, that wasn’t it. I was running only one word options, but I forget that this message happens, but wasn’t related to the multi-multi-tiered hierarchy. I still can’t do a three+ level hierarchy of dropdowns.
-
-
-
I am having the same issue. I cant get the 2nd selection to create the drop down. any ideas?
-
-
for this formula —- what if I had three columns in my named ranged (not two) how would the match formula change?
formula: =ISERROR(VLOOKUP(E3,INDEX($A$2:$B$6,,MATCH(D3,$A$1:$B$1)),1,0))-
I have the same question!
-
-
you’re the best, thank you so much
-
it was the good one
-
I had one excel file with complete functions and formulas along with logic and examples. Unfortunately, I had missed that file. If you have these kind of file, please share the same with me. Thanks…
-
hi, i have the same trouble as Abhishek Goyanka,
was this solved?
-
Creating a Dependent Drop Down List in Excel
I have categories name with White spaces, drop down is not working in that case.
Any solution -
Excellent stuff
Thanks -
good
-
Very excellent job, thank you very much.
-
Very Helpfull task
-
Wow! This was so helpful and exactly what I was looking for. I knew the solution had to be much more simple than I was originally planning to try.
-
Hi Could you possibly help me with a slightly bigger formula?
-
Where did my comment go?
-
I have a issue with name box in excel, which does not accept hypen “/” for eg: “AM/NAME” , please give me suggestion for this issue.
i am trying to populate dependent drop down box -
HI, How can I make the drop down list works for multiple cells and not just in a unique cell?
-
thanks alot very usefull trick
-
Hi Sumit,
How to update the dependent list when you change primary list after initially making some selection? Right now if you select the US and then Alaska, after that if you change it to India, the state still remains Alaska. Please help.
Thanks-
Hello Abhishek.. This can be done using VBA. Will try and create it and share with you
-
Hi Sumit,
Really appreciate the help. Please let me know if you are able to write VBA script which accomplishes the task. Thanks again.
-
-
-
I want to create two cells dependent on the data entered into the first cell. So say I have a list of Company Branches listed by city. Then I have 6 multiple lists that list the Foremen that work in each city AND I have 6 lists of Superintendents that work in each city. I created the city list in cell B2. In the Superintendents cell E3 I used =Indirect(B2) and it lists all the Superintendents working in the city showing. Now in cell E2 I want to have the Foremen that work in each city. I tried =Indirect(B2) which gives me the same list in cell E3. How do I get E2 tied to B2????
-
i have my drop down all done, but when i to look at the list , there is nothing showing, can you help me please
-
Hi there, is there any way you know to do this but with a list of all countries and regions of the world without having to create as many columns as countries exist? I have the list with two columns, each row per region/country… When I select one of the countries, I need the drop down list to display all the regions of that country.
-
Thanks Sumit for sharing this! However, I have find two errros:
1 – While addition to the data set (As states) and consequently using indirect formula as Indirect(States Name) doesn’t show any options in list.
2 – Is there any way in which cells should appear empty for that particular row if we change any data set?
-
Hey Sumit, I have a doubt – when you choose US in Cell -E2 then the other drop down list in cell:F2 shows US cities. Lets assume, we select Alaska as city in F2 but at the same time we change the country again US to India in E2, then F2 field still shows Alaska.
Is there a way cell should appear empty if we change the country ?
-
How do i fix this? its not letting me do the data validation following the exact steps.
-
I also have the same mistake…anybody could fix it?
Thanks!!!
-
-
How would you this with a third drop down based on BOTH the previous drop downs? For instance, adding a “City.”
-
Hi Tyler.. Thanks for dropping in.. You can create the third drop down in the similar way. In this case. city would be dependent on selected state. You would need to create named ranges for all states, and the formula would be =INDIRECT(States Name)
-
Comments are closed.
This example describes how to create dependent drop-down lists in Excel. Here’s what we are trying to achieve:
The user selects Pizza from a drop-down list.
As a result, a second drop-down list contains the Pizza items.
To create these dependent drop-down lists, execute the following steps.
1. On the second sheet, create the following named ranges.
Name | Range Address |
---|---|
Food | A1:A3 |
Pizza | B1:B4 |
Pancakes | C1:C2 |
Chinese | D1:D3 |
2. On the first sheet, select cell B1.
3. On the Data tab, in the Data Tools group, click Data Validation.
The ‘Data Validation’ dialog box appears.
4. In the Allow box, click List.
5. Click in the Source box and type =Food.
6. Click OK.
Result:
7. Next, select cell E1.
8. In the Allow box, click List.
9. Click in the Source box and type =INDIRECT($B$1).
10. Click OK.
Result:
Explanation: the INDIRECT function returns the reference specified by a text string. For example, the user selects Chinese from the first drop-down list. =INDIRECT($B$1) returns the Chinese reference. As a result, the second drop-down lists contains the Chinese items.
Home / Advanced Excel / How to Create a Dependent Drop-Down List in Excel
The dependent drop-down is all about showing values in a drop-down list according to the selection of the value in another drop-down.
Today, in this post, I’d like to share with you a Simple 7-Steps Process to create this drop-down. But first of all, let me tell you why it is important. In the below example, you have two drop-down lists. The size drop-down is dependent on the product drop-down.
If you select the white paper in the product cell then in size drop-down will show small and medium. But, if you select gray paper then its size will be medium and large.
So here the basic idea to create a dependent drop-down list is to get the correct size as per the product name. Let’s get started.
For creating a dependent drop-down list we need to use named ranges and indirect functions.
- First of all, you have to create named ranges for drop-down lists. For this, select the product list. Go to -> Formulas -> Defined Names -> Create from selection.
- You’ll get a pop-up. Tick mark “Top Row” & click OK.
- By using the same steps, create two more named ranges for sizes. One is for white paper and the second is for the gray paper.
Quick Tip: By using this method to create a named range, the value in the first cell will be considered as the name, and the rest of the values as the range. You can also use a dynamic named range for this.
- Now select the cell where you want to add the product drop-down and Go to -> Data -> Data Tools -> Data Validation.
- In the data validation window, select “List” and in “Source” enter the below formula and then click OK.
=Indirect(“Product”)
- Select the cell where you want to add a size drop-down list. Go to -> Data -> Data Tools -> Data Validation.
- In the data validation window, select “List” and in “Source” enter the below formula and click OK.
=Indirect(“A5”)
Finally, your dependent drop-down list is ready.
How Does it Work
First, you have created three named ranges. Then we used one named range to create a product drop-down. After that, for the second drop-down list, you have used the indirect function & refer to the value in the product cell.
If you notice, our size-named ranges have a name equal to the values we have in the product drop-down.
When we select “WhitePaperSheet” in the product cell, then in the size cell indirect function refers to the named range “WhitePaperSheet” and when you select “GreyPaperSheet” it will refer to the named range “GreyPaperSheet”.
Three-Level Dependent Drop-Down List
In the above example, you have created a two-level dependent drop-down list. But sometimes, we need to create a list with three-level dependencies. For this, all you have to do is create a third drop-down list which is dependent on the selection of the second drop-down list.
Let’s say we want to add a drop-down list with “Length x Width” of the sizes for paper sheets.
And, for this, you have to create a third drop-down list that will show the “Length X Width” as per size selection.
Here are the steps:
- Create three more named ranges using the same method which we have used above.
- Select the cell where you want to insert your third drop-down.
- Open drop-down options & insert the following formula in the source.
=Indirect(“C5”)
- Click OK.
Now, your three-level drop-down list is ready
sample-file
We begin with a table of Divisions where each Division contains a list of Apps.
The goal is to have the user select from the first drop down list a Division name. Next, the user will select an App from the second drop down list. The key is to only display the apps associated with the selected Division from the first drop down list.
NOTE: In the real world, the list of Divisions and Apps would likely be placed on a separate (possible hidden) sheet, or the list would be placed somewhere far away from the data entry portion of the sheet where the user is not likely to ever find. For this example, we are placing the list close to the user-area to make the demonstration easier to follow.
Creating the First Drop Down List (Division)
The first drop down list will allow the user to select a Division. This one is simple.
We begin by creating a Data Validation drop down list for cell A5 that points to the Divisions listed in cells F4 through H4.
- Select cell A5
- Select Data (tab) -> Data Tools (group) -> Data Validation
- In the Data Validation dialog box, set Allow to “List” and Source to “=$F$4:$H$4”
- Click OK
To get the drop down list to appear for multiple rows, select A5 and copy/paste the contents to adjacent cells (ex: A6:A20).
Creating the Second Drop Down List (App)
As stated earlier, we want the second list of Apps to only show items based on the selected Division from the first drop down list.
Using the OFFSET function
We will use the OFFSET function to select Apps from one of the three listed Divisions.
If you’re not familiar with the OFFSET function, it allows us to start from a defined point then moves away from that point by a set number of rows and/or columns. This establishes a new start point. From here, we can select a set number of rows and/or columns.
The OFFSET function has the following syntax:
OFFSET(reference, rows, cols, [height], [width])
- reference – the cell or range of cells you want to base the offset (e. the starting point).
- rows – the number of rows down or up you want to move. A positive number moves down; a negative number moves up.
- cols – the number of columns right or left you want to move. A positive number moves right; a negative number moves left.
- [height] – the number of rows you want returned. This must be a positive number.
- [width] – the number of columns you want returned. This must be a positive number.
NOTE: For an explanation of the OFFSET function, see this post/video.
Ultimately, we need to create this formula in the Data Validation dialog box.
Since the Data Validation dialog box does not possess the IntelliSense feature that is so helpful when writing formulas, we will write and test our formula in a standard Excel cell.
Once we have the formula working, we will transfer it to the Data Validation tool for its final test.
Establishing the Starting Point
We will always begin our search for Apps from the upper-left corner of our table (cell F4).
Start the OFFSET function as follows.
=OFFSET($F$4
We need to make this reference to cell A4 as an absolute reference so each copied/pasted version begins from the same point.
Moving Down or Up
Next, we tell OFFSET how many rows to move down or up. The Apps list begins 1 row below our start point, so we assign a value of 1 to the rows argument.
=OFFSET($F$4, 1
Moving Right or Left
Now we tell OFFSET how many columns to move right or left.
This is determined by the user’s Division selection from the first drop down list.
For this, we can use the MATCH function to locate the selected Division in cell A5 from the list of Division in cells F4 through H4. We also need to match exactly (0 in the last argument).
=OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0)
NOTE: We only “locked” the “A” part of the “A5” reference because we don’t want to point to other columns when we replicate this to adjacent cells, but we do want to point to other rows when creating additional drop downs. If that’s a bit unclear, stick with us because it will become clearer very soon.
If we highlight the MATCH portion of the formula and press F9, we can see MATCH returns a number indicating the discovered position in the search range.
NOTE: Remember to press CTRL-Z to undo your formula back to its original structure.
The Problem with MATCH
A minor issue we have with MATCH is that it counts cells beginning with the value 1.
This means that “Productivity” is in the first column of the data, “Game” is in the second column, and “Utility” is in the third column.
Because we’re trying to inform OFFSET how many columns to move to the right, these values are incorrect.
If we want “Productivity”, we don’t want to move left or right. If we want “Game”, we want to move 1 column to the right, and if we want “Utility”, we want to move 2 columns to the right.
We need to reduce the returned value of MATCH by 1 to adjust for this discrepancy.
=OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1
Selecting the Height to Return
We dropped 1 row from the start point to land on the first App. We also moved right to the proper Division column.
The tricky part is to determine the number of rows to select. This will be the list of Apps that will drives the second drop down list.
Notice that our three lists do not contain the same number of items.
Temporarily, we will treat each list as if they contained 15 items. This will allow us to see if the [height] argument is working. Later, we’ll make the height selection dynamic so it will return the perfect number of Apps for our second drop down list.
=OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1, 15
For any columns that contain less than 15 Apps, this will produce empty slots in the Data Validation drop down list. If you’re okay with that, you can leave the [height] argument set to the largest expected list length. This could be a problem if one list has hundreds of items while another list has only dozens.
Like I said a moment ago, we’ll start statically then make it dynamic later, so we eliminate the empty slots.
Selecting the Width to Return
We only ever want a single column of Apps to be returned by the OFFSET function, so we will set the [width] argument to 1.
=OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1, 15, 1)
Setting Up Data Validation
Now that we have completed our test formula, it’s time to use the logic in a Data Validation drop down list.
- Select cell B5
- Highlight the OFFSET/MATCH formula displayed in the Formula Bar
- Copy the formula to memory
- Press ESC to get out of Edit Mode
- Select Data (tab) -> Data Tools (group) -> Data Validation
- In the Data Validation dialog box, set Allow to “List”
- In the Source field, paste the recently copied OFFSET/MATCH formula
- Click OK
Testing the OFFSET/MATCH Formula
If we select a Division from the first drop down list (A5), we then see the list of related Apps in the second drop down list (B5).
Because we are using a fixed [height] argument, we see blank slots for any Division where the Apps list is less than 15.
Getting the Perfect Height
To get a list of Apps that do not display blank slots at the bottom, we need to calculate the height of the selected Division’s Apps.
We need to take the previously hard-coded “15” for the [height] argument and make it dynamic.
Enter the COUNTA Function
A perfect way to determine the number of Apps in a give Division is to use the COUNTA function.
As a test, we select an unused cell in our sheet and write the following formula:
=COUNTA(F5:F19)
This yields a result of 15.
If we point the COUNTA function to G5:G19, we get 12, and if we point the COUNTA function to H5:H19, we get 13.
We don’t want to hard-code the count range, we want the range to be based on the selected Division.
We can replace the hard-coded range with the same OFFSET formula used earlier.
=COUNTA(OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1, 15, 1)
NOTE: the “15” defined in the [height] argument represents the largest number of Apps we would expect to see in any given Division. You should set this value to whatever number you believe you would never reach, such as =COUNTA(OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1, 500, 1).
Testing the COUNTA Formula
In cell A5, if we select “Productivity” we are returned a value of 15. If we select “Game” we are returned a value of 12, and if we select “Utility” we are returned a value of 13.
Updating the Data Validation Formula
Our final step is to update the formula previously placed in the Data Validation tool for cell B5 to include this dynamic logic for [height] calculations.
- Select the cell that contains the temporary COUNTA formula
- Highlight the COUNTA/OFFSET formula displayed in the Formula Bar
- Copy the formula to memory
- Press ESC to get out of Edit Mode
- Select cell B5
- Select Data (tab) -> Data Tools (group) -> Data Validation
- In the Source field, remove the “15” from the original formula and paste the recently copied COUNTA/OFFSET formula
- Click OK
=OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1, COUNTA(OFFSET($F$4, 1, MATCH($A5, $F$4:$H$4, 0) – 1, 15, 1)), 1)
Testing the Updated Formula
If we select a Division form cell A5 that has less than 15 Apps, we are no longer presented with empty slots at the bottom of the Apps drop down list (B5).
Copying the Data Validation to Adjacent Cells
To replicate the second Data Validation drop down list to the row cells below cell B5:
- Select cell B5
- Press Copy
- Select your destination cells (ex: B6:B15)
- Right-click the highlighted range and select “Paste Special…”
- In the Paste Special dialog box, select Validation and click OK
Final Test
You are now able to select a cell from the “Select Division” column, select a Division, then click the corresponding “Select App” cell to be presented with the Apps for the selected Division.
Granted, I did say that we would use a single formula. I never said it would be short and simple.
The nice thing is that with a small bit of practice, this formula is fairly easy to write. You could even copy/paste it form project to project, reusing it with just minor modifications.
I think it’s easier to stick to a single strategy for building these dependent drop down lists and get good at it, versus learning dozens of other techniques.
Yes, some of those other techniques may be more efficient or have more features, but unless you need fancy and exotic, this one will do just fine.
Practice Workbook
Feel free to Download the Workbook HERE.
Published on: March 26, 2020
Last modified: February 26, 2023
Leila Gharani
I’m a 5x Microsoft MVP with over 15 years of experience implementing and professionals on Management Information Systems of different sizes and nature.
My background is Masters in Economics, Economist, Consultant, Oracle HFM Accounting Systems Expert, SAP BW Project Manager. My passion is teaching, experimenting and sharing. I am also addicted to learning and enjoy taking online courses on a variety of topics.
Learn how to create dependent drop-down lists (also known as cascading validation) in Excel. This technique does NOT require named ranges.
Bottom line: Learn how to create cascading or dependent drop-down lists (also known as cascading validation) in Excel. This technique does NOT require named ranges. If you don’t mind using named ranges then there are a few links at the bottom of the page with solutions that will be easier to implement.
Skill level: Intermediate
Functions used: OFFSET, MATCH, COUNTA, COUNTIF, INDIRECT
Drop-Down (Data Validation) Lists
Before we dive into dependent lists, if you are unfamiliar with drop-down lists in general (also known as data-validation lists), I strongly suggest you check out my tutorial for creating drop-down lists and also this post for making drop-down lists dynamic.
What is a Dependent Drop-down List?
Leah asked the following question, “How do I create a drop-down list where the list of choices changes when I select an item in another list?”
You can see an example of this in the screencast below. When I select “Coffee” from the validation list in cell B4, the list in cell E4 displays different types of Coffee.
When I select “Wine” from the list in cell B4, the list in cell E4 displays different types of Wine.
These are called dependent or cascading drop-down lists because the 2nd list depends on the choice made in the first list. This technique requires the use of the OFFSET function to create the dependencies, and it’s a great function to learn.
Step-by-Step Guide to Dependent Drop-down Lists
The rest of this article will explain how to create these dependent lists in your own workbook. You can also download the example file to follow along, or just copy the sheets into your workbook.
Step 1: Prepare the Source Tables
Our first step is to create the source tables that we will use for the contents of the drop-down lists.
In the image above, the ‘Lists’ sheet contains the lists for each drop-down. The list in column B contains the Category items for the parent list. The parent list is the list where we will make the first choice.
We then use the list in columns D:F on the ‘Lists’ sheet to populate the child list with items. The child list is the second list of choices that will be dependent on the selection in the parent list.
The first column in this table (column D) contains the Categories. These are the exact same names that are in column B. The second column in the table (column E) contains the different types for each category. This is where the relationship between the Category and Type are created.
It’s also important to note that the child list needs to be sorted for this technique to work. In the image below you can see that I sorted column D so that all the Category items are grouped together in the list.
These lists originated from a much larger data table that contains transactional sales data. To create the lists I needed to extract all the unique values for each list.
Fortunately, Excel has some great built-in tools that allow you to remove the duplicates.
One way is to use the Remove Duplicates tool that is located on the Data tab in the ribbon.
You could also create a pivot table to quickly list the unique values in the Rows area of the pivot. Then copy/paste the results to the ‘Lists’ sheet that contains the source tables.
I won’t go into details on these techniques, but they will make it very fast to create and update you dependent lists. If your lists change frequently with new items, then I would recommend the pivot table method because you can simply refresh the pivot table to generate your new list.
Step 2: Create the Parent Drop-down List
Ok, now that we have the source data lists setup we can create the drop-down lists. We will do this with in-cell data validation lists.
Dependent drop-down lists are not a built-in feature of Excel. Therefore, we need to get creative with some functions and formulas to create the dynamic dependencies between the lists.
With cell B6 selected on the ‘Dropdowns’ sheet, click the Data Validation button on the Data tab of the ribbon.
The Data Validation window will appear.
- First, choose “List” in the Allow drop-down list.
- Then enter the OFFSET formula in the Source box (see explanation below).
- Press OK.
We could put the following reference in as the Source: =Lists!B2:B4
However, we want the source list to be dynamic. Dynamic means that the list will automatically expand as we add more items to it. We don’t want to have to change the source reference every time we add items to the list.
The OFFSET function helps create this dynamic range reference, and returns a reference to a range of cells based on the coordinates you specify. It has the following arguments.
=OFFSET(reference, rows, columns, [height], [width])
Our Formula: =OFFSET(Lists!B1,1,0,COUNTA(Lists!B:B)-1,1)
Here is a quick explanation of each argument in the formula:
- Reference – Think of this as the cell that is the starting point for the range. In this case we are starting in cell B1 on the ‘Lists’ sheet.
- Rows – We actually want to move the starting point down to cell B2. The rows argument allows us to specify how many rows down we should move (offset) the starting point. We put a “1” for this argument to move the starting point down to cell B2.
- Columns – This argument would move the starting point to the right a specific number of columns. In this case we want to stay in column B, so we leave this argument blank or put 0 (zero).
- Height – This is the height of the range specified in number of rows. In this case we are using the COUNTA function to count the number of rows that contain text in column B. =COUNTA(Lists!B:B). This will return 4 since there are 4 rows with text in column B. We subtract 1 because we don’t want to include the header row in our list.
- Width – This is the width of the range specified by number of columns. Our range is only 1 column wide (column B) so we put a 1 here.
You should now have a drop-down list in cell B6 that contains all the Category items in the list on the Lists tab.
Excel Tables and the Structured Reference Alternative
If you are storing your lists in Excel Tables (which I highly recommend), then you could use the following formula instead.
=INDIRECT(“tblCategory[Category]”)
Since Table references expand and collapse automatically when rows are added/deleted, you do not need to use the OFFSET function.
Step 3: Create the Child (Dependent) Drop-down List
We now need to create the child list, which is dependent on the selection of the parent list.
The OFFSET function can be used for this list as well. We just need to make a few adjustments to make it dependent on the selection in the parent list.
Here is the formula for the child list:
=OFFSET(Lists!$D$1,MATCH(B6,Lists!$D:$D,0)-1,1,COUNTIF(Lists!$D:$D,B6),1)
Here is an explanation of each argument in the OFFSET formula:
- Reference – Start in cell D1 on the Lists tab. This is the top left cell of the table that lists the child items.
- Rows – Use the MATCH function to find the first row that matches the item selected in the parent list. Cell B6 is the reference to the cell that contains the parent drop-down list. This is basically a lookup function that returns the row number of the first matching item. Subtract one to account for the header row.
- Columns – Specify a “1” to move one column to the right. The formula is going to find the matching range in column D, then we have to move over one column to the right to return the range of matching values in column E.
- Height – Use the COUNTIF function to count the number of occurrences of the parent item in Cell B6, “Coffee”. This returns a 4, which means the range will be 4 rows high.
- Width – The range is one column wide (column E).
The child drop-down list in cell E6 should now be dependent on the selection made in cell B6 on the ‘Dropdowns’ sheet (parent list).
Excel Tables and the Structured Reference Alternative
As an alternative, you could use the structured reference formulas with the Excel Table names instead of cell addresses. The Table formula would look like the following.
=OFFSET(INDIRECT(“tblType[#Headers]”), MATCH(B11,INDIRECT(“tblType[Category]”),0), 1, COUNTIF(INDIRECT(“tblType[Category]”),B11),1)
It’s not as pretty because you have to add the INDIRECT function for each table reference.
Dependent Drop-downs WITHOUT Named Ranges
There are a few different ways to create dependent drop down lists in Excel. The main advantage of this method is that it does NOT required the use of named ranges.
Named ranges are a great feature, but can be very confusing for some users. Therefore, I recommend not using named ranges unless you are confident that all future users of your model will understand them.
If you don’t mind using named ranges then the following articles provide some awesome tutorials on other ways to create the drop-downs.
- Create Dependent Lists With INDEX by Roger Grovier at Contextures
- Dependent Drop Down Lists from a Sorted List by Debra Degleish at Contextrures
- Create Dependent Drop-down Lists with Conditional Data Validation & Slicers as an Alternative to Conditional Drop Downs by Jeff Lenning at Excel University
- Great VBA & Non-VBA solutions by Jeff Weir and Roberto Mensa over at Chandoo.org
Download the Sample Workbook
You can download the sample workbook below to follow along, or simply copy the sheets into your own workbook.
How to Search a Drop-down List
Excel doesn’t have a built-in option to search drop-down lists for a particular item, but I’ve created an add-in that gives you that option. It’s called List Search and you can access that add-in here:
Click here to download the List Search Add-in
I hope this post is useful for you! Please leave a comment below with any questions or suggestions.