Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Jon Acampora
November 18, 2014
Bottom line: Learn how to create dependent drop-down lists (also known as cascading
validation) in Excel. This technique does NOT require named ranges. If you dont mind using
named ranges then there are a few links at the bottom of the page with solutions that will be
easier to implement.
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.
Click here to view the screencast animation in your browser.
When I select Wine from the list in cell B4, the list in cell E4 displays different types of Wine.
These are called dependent 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 its a great function to learn.
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.
Its 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.
How to Create the Lists
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 wont 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.
With cell B6 selected on the Dropdowns sheet, click the Data Validation button on the Data
tab of the ribbon.
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 dont 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.
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 dont 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.
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.
=OFFSET(Lists!$D$1,MATCH(B6,Lists!$D:$D,0)-1,1,COUNTIF(Lists!$D:$D,B6),1)
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).
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)
Its not as pretty because you have to add the INDIRECT function for each table reference.
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 dont mind using named ranges then the following articles provide some awesome
tutorials on other ways to create the drop-downs.
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
Please share
Jon Acampora
Welcome to Excel Campus! I am excited you are here. My name is Jon and my goal is to help
you learn Excel to save time with your job and advance in your career. I've been an avid Excel
user and VBA developer for 10+ years. I am also a Microsoft MVP. I try to learn something new
everyday, and want to share this knowledge with you to help you improve your skills. When I'm
not looking at spreadsheets, I get outdoors and surf. :) more about me
Good article, is it possible to have 2 drop down lists with the same values, but when 1 value is
selected in the first list the second lists value updates as well?
Not sure if its completely clear but lets say I have a list of months as my range of data, I have a
cell that is a drop down list of the months and another cell that is also a dropdown list of the
months but on a different sheet, and Im asking if one can be selected and affect the other and if
its reversible. So I can choose the month in either cell and the other cell will update based on the
other one.
Reply
Hi Ollie,
That can be done with a very simple macro.
Range("A4").Value = Range("A1").Value
That line of code will need to be placed in the Worksheet_Change event macro for the
sheet that the drop-downs are on.
The Worksheet_Change event when run when any change is made in the worksheet, so
you might want to limit it to only the cells with the drop-down by using the Target cell
and Intersect method.
Reply
Jon,
Ive looked at the additional workbooks for the 3 lists, but feel my example doesnt fit.
Example.
Category: 1) Condo, 2) Apartment
Type 1: 1) Chicago, 2) NY, 3) LA
Type 2: 1) Company A, Company B, 3) Company C
In this particular example the 3 different companies may or may not have condos and apartments
and the three different cities.
Comparing the above to your beverage selection format, if the user selects Condo and
Chicago, how would the third selection know what company to go to? If searching for
Chicago it may show companies that have apartments in Chicago too. Or no? Id like to avoid
creating multiple tables for each scenario.
I came up with the below formula for the third drop-down but it differently has interesting
quirks: 1) when opening the workbook, the drop-down list only works after going into the data
validation formula and 2) when it does work, its slow at generating the drop-down list.
=OFFSET(Sheet1!$G$1,MATCH(C3&C5,Sheet1!$G:$G&Sheet1!$H:$H,0)-
1,2,COUNTIFS(Sheet1!$G:$G,C3,Sheet1!$H:$H,C5),1)
Thx
Reply
Hi Rodger,
Great question! It looks like you are on the right path with a multiple criteria lookup with
the Match function. Instead of concatenating the lookup values in the formula and using
an array formula, you might want to try doing the concatenation in another helper cell
and column in your tables. I will try to write up another solution on this in the future. It
would make for a great example. Thanks again!
Reply
Hi Jon,
I have one question. I have a drop down box that returns either yes or no (C1), is it possible for
the next cell down to return a dependent list if C1 is selected yes, to return text of N/A if C1
was selected as no and to be blank if nothing is selcted in C1?
Thanks again!
Reply
when I get some time. Let me know if you have questions. Thanks!
Reply
Jon,
Thank you very much for a very clear, and very helpful article.
I wonder if you might be able to help adapt your formulas for a problem Im having?
Im keeping an accounting spreadsheet for my business. The first sheet keeps records of all bank
transfers. Each transaction is detailed on a row, and the number of rows is of course ever
increasing with new transactions.
On each row I want to create a parent drop-down list to select a type of transfer (Income,
Overheads, Expenses, etc, etc), and then a child drop-down list to provide more detail for that
(e.g. if its an Expense travel, food, stationery, etc, etc).
Easy enough to do just the once, but essentially Id like to be able to copy and paste this across
each new row (or better yet, just set each of the columns with a single data validation formula),
without having to amend the child drop-down formula each time, so that its referencing the
correct, new parent drop-down list.
Thanks in advance!
Jez
Reply
Hi Jeremy,
Great question! You could use Power Query to create a table with a list of unique values
from the data table. Once it is setup all you have to do is refresh the query to repopulate
the table with any new unique values. That table will be the source for the drop-downs
listed above. I dont have any tutorials on how to set that up yet, but will create
something in the future. I think there could be a lot of uses for this. Thanks!
Reply
Here is a video from my friend Mike Girvin on how to create the unique list for the drop
down list with Power Query.
https://www.youtube.com/watch?v=3ICk356kEZo
Reply
Another killer post! Just used this and it was perfect! I had been trying a method with defined
ranges, but things got messy very quickly. The error checking feature was very helpful as well.
Thanks!
Reply
I used your offset formula in name manager but its shows only start 3 records.for
dependent list
can u please help us ASAP
Reply
Thanks Nate!
Reply
Anders - March 31, 2016
Hi Jon
I have a range of courses that should be prioritized. How can I make a drop down list for 2nd
prio etc. that excludes the already chosen courses?
Reply
Hi. I need assistance to create 2 drop down lists with multiple choices selections on the same
sheet. They will have their own lists.
Reply
Hi,
Thanks,
Uma Manickam
Reply
THank you so much for sharing this tutorial! Made my day!!! I was looking everywhere and
trying so many dead end things on my own Thank you thank you!
Reply
Jon Acampora - February 1, 2016
Awesome! Thanks for letting me know Dan. You made my day too!
Reply
Hi Jon,
Thanks for this. Just a quick question is it possible to create the drop down lists with a 1 to 4
relationship?
I.e. One parent list and 4 different child lists dependent on the parent?
Reply
Hi Karl,
Great question! I added a new file in the download section above for multiple
dependents. The file includes a second drop-down that is dependent on the first.
You will basically create additional tables in with the relationships. So in this case I
created another drop-down for size. The size is dependent on the first drop-down
(Category: Coffee, Tea, Wine). There are different sizes available for each drink type
(Small, Medium, Large, etc.).
Once you have the table setup its just a matter of changing the formula to return values
from the new table. Its in column G:H on the Lists tab.
Is there a way to display multiple rows for each item in the 1st table. For example if coffee
regular was selected it can list 2 sugars 2 milk in a single column?
Reply
Hi Jen,
Im not sure I fully understand your question. Do you want formulas that return multiple
items in multiple cells based on what is selected in the drop downs?
Reply
HI JON, NOT SURE IF THATS WHAT THEY WERE ASKING BUT THAT IS A
QUESTION I HAVE. HOW CAN I INPUT A VARIABLE IN A CELL THAT
CHANGES DEPENDENT ON WHAT IS SELECTED IN A DROP DOWN
MENU THAT SAID FORMULA USES.
Reply
http://www.excelcampus.com/lookup-formulas-free-training/
Reply
Hi Jon,
You really made my life easy. Thanks a lot for your help. I have a problem here. I created a list
and a dependent list successfully as you have explained in your article. I have the Parent List
Category and the Child List Sub-category. I want that the field Sub-Category field should
be reset or go blank when I change my selection in the Category dropdown list. Please revert
as soon as possible.
Reply
Reply
Thanks Hagit!
Reply
Reply
Hi Sara,
Checkout the file named 3 Lists. It has an example of how to do this. Let me know if
you have any questions. Thanks!
Reply
Thanks for this! This is the first one Ive actually gotten to work. How do I now copy this
formula down a set of rows? Do I have to manually change the row number for each drop down
or is there another way to make it dynamic?
Thank you!
Reply
Hi Randy,
You should be able to copy the dependent cell down. Just make sure the lookup_value in
the Match function is NOT anchored. That means there should not be any dollar signs
before the row number.
In the following part of the formula make sure there are no dollar signs in front of the row
number: MATCH(B6,
The reference will then be relative, and you should be able to copy down the cell that
contains the validation list.
Reply
Thanks Jon!
This is working great for me. Is it possible to use above formulas also in userforms?
Reply
Hi Bastian,
Are you referring to the combobox form control that you put on a worksheet? Or
comboboxes in a userform? If its the form control then you will probably want to use
one of the named range methods to create the dependent lists. Here is a tutorial by Debra
Degleish at Contextrures on creating dependent comboboxes in userforms.
Reply
I am trying to create dependent drop down lists. I have tried a number of different tutorials,
formulas and options and I am not sure where I am going wrong. I can get the first drop down
list no problem, but the second drop down list will not populate. It doesnt give me an error at all.
I have tried tutorials with their information and it has worked just fine, but it does not with my
information. So I am wondering if the data I am trying to use is the problem? A sample of my
data is below. Any feed back would be appreciated.
Reply
Hi Jon,
Amazing post. Thanks very much! It seems to be working for me, but what Im wondering about,
is what I need to do to make the above work for a third list which depends on the first and second
one? i.e. an additional level down the hierarchy.
Thanks!
Reply
Hi Hamid,
Thank you! Im glad you found it useful. I added a file to the downloads section above
that contains the 3rd list.
You basically just need to create another table that contains all your types from table 2.
These become your categories for table 3, and you can then add types for table 3 that
will be the options in your third drop-down list. The formula remains the same, it just
references the new table/list that contains the third set of options. Checkout the file and
let me know if you have any questions.
Thanks again!
Reply
Thanks Jon! I had actually already created the same function, but its showing me
duplicates and not showing all values. Although correctly specified, the
COUNTIF isnt picking up entire range. Would I be able to send file to you?
Thanks!
Reply
Reply
Sorry I dont get it. Whats the use of it. You choose category ( coffee ,tee, etc) and the type, and
then what ?
Reply
Hi Laci,
This technique can be used when you want your user to make selections from two or
more lists. The selections might control what is displayed on a dashboard, run scenarios
for a sensitivity model, or simply do a vlookup based on multiple criteria.
The dependent drop down just means that the choices in the second list (drop down)
depend on what is selected in the first drop down. If the user chooses coffee in the first
drop down, then only types of coffee are going to be shown in the second drop down.
I hope that helps. Please let me know if you have any other questions. Thanks
Reply
The first link has an optional bit of VBA to clear downstream dropdowns if the upstream one
changes.
The 2nd link accomplishes the same kind of thing, without VBA, by making it impossible to
clear upstream dropdowns until all downstream ones are cleared.
I have another approach up my sleeve that uses only formulas, and allows you to have non-
unique subcategories. Just need to write it up.
Reply
Thanks for sharing Jeff! I added your links to the article as well.
Reply
Following my previous, I am afraid to confirm you that in the web page of Chandoo there is an
example on the same thema more clear, easy and quick to apply than yours. Any case, thanks for
your effort. Regards, Livio
Reply
Hi Livio,
Im sorry you had trouble following the explanation. Thank you for letting me know. The
formulas are located behind the scenes as the source of the validation. Select cell E6, then
select the Data tab on the menu and click the Data Validation button. You will see the
formula in the source box.
If you dont mind using named ranges then I agree that there are easier solutions to this
problem.
Reply
interesting application, but I am not able to reply in my spreadsheet. Not easy understand
application of OFFSET formula. The sample workbook to not show formulas in the cells; it was
a help to look the formula in a different excel language than english and check the formula into
the cartel. Please
Thanks
Reply
However, IMO using Excel tables with named ranges for dynamic data validation is superior to
producing Frankenformulas, and easier as well.
Reply
Hi Frank,
Yes, I completely agree. I will make it more clear that this technique is for those that do
not want to use named ranges. Depending on the user of the model, I tend to avoid named
ranges because they can be confusing for users that have not learned them yet.
My next post will explain how to create the fake drop-downs. Im sure youve already
figured it out
Thanks again!
Reply
Reply
Hi Jeff,
Im guessing you left another comment and it did not come through. Ive been having
issues with comments in the latest version of wordpress
Thank you for the links. I will add those to the links in the article. This solution was
meant for those that do not want to use named ranges or VBA.
Using named ranges definitely makes this process much easier. I tend to avoid using
named ranges because most users are not familiar with them, and they can be confusing
for some.
Reply
Reply
Hi Leonid,
That is a great suggestion! I updated the file to include that check. It basically uses the
same OFFSET formula as the child list, with a COUNTIF to check if the parent and child
items are related.
I agree that it is a compromise. This example is meant for those that cant use macros and
want to avoid named ranges. Thanks again for the tip!
Reply
Once you choose Coffee, for example, then choose Decaf, if you then change the Coffee choice
to Wine, the Decaf still shows in the sub-data validation. I suggest this be an xlsm and whenever
the 1st choice changes, the sub-choice should be cleared.
Bob Umlas, Excel MVP
Reply
Jon Acampora - November 20, 2014
Hi Bob,
Sorry to not get back to you all sooner. For some reason I was not receiving comment
notifications.
This is a great point! This solution is meant for those that cant use macros, and want to
avoid named ranges. Ill be the first to admit that there are much better ways to do this if
you can use either VBA or named ranges. I will make that more clear in the opening
paragraph, as I dont want to waste anyones time.
Leonid, has a great suggestion and I will update the file with a formula to validate the
second entry.