|
Home > Validation > Dependent Drop Downs > Index Tables Dependent Data Validation with INDEX and Excel Tables
|

This video shows how to set up multiple dependent drop down lists, using 2 Excel tables, and 3 named ranges. There are written steps below the video.
In this example, there are two named Excel tables:
You can get the completed sample file in the Sample Files section, further down the page.
Or, follow the steps below, for a quick overview on how to set up the workbook.
To set up a data entry sheet, follow these steps:
Open a new workbook in Excel, and name the first sheet - Data Entry
Data Entry table has been created on a sheet which itself has been named Data Entry - but it could have any name. First, the headings are typed on the sheet.

Next, a Table was created using the Table command on the Ribbon's Insert tab.
When the tables are created, you can choose whatever Formatting you want for the table from the Table Styles menu. In this case the Style chosen was Table Style Medium 2.

I also chose to give this table a name in place of the default Table1 and I named it tblData

After the other tables are set up, data validation drop downs will be added to this table.
These will be dependent drop down list, with each list showing the items based on your selection in the previous column.

In exactly the same way a list of the data required for the Data Validation was typed on another sheet (in reality it could be on the same sheet if required) and this was converted into a Table by the same method and this was given the name tblVal.

There are 3 named ranges used in this method, and the setup for each range is described below.

This is the range that will be allocated as the data validation list for the column Regions in tblData. This is a fixed list, in that it relates only to the first column of data entry. The other named ranges will help to derive the single range that will be used for every other column on the data entry table, as each of these will be dependent upon the preceding column to the left.
For this range, I have used structured table referencing to refer to just the cells in the first column of the tblVal data, and only for those cells within this column that contain data. Using Formulas > Name Manager > New, I created the formula in the Refers To box as
=INDEX(tblVal[Regions], 1,1):INDEX(tblVal[Regions], COUNTA(tblVal[Regions]))

With structured referencing, the reference tblVal[Regions] will return the column of data called Regions in the Table called tblVal. In this case it will return the range $D$8:$D$18. The great thing about tables is, although the returned range looks like an absolute range, it is in fact dynamic, and will grow if more data rows are added (and shrink if rows are deleted from the table.
However, this range, only has entries in cells D8:D11, and cells D12:D18 are empty. For our data validation, we only want a list of the cells with data so we need to adjust the range that _Regions returns to account for this. We do this with the INDEX function.
In the Refers to formula:
As a result, the named range _Regions refers to D8:D11 and when used with data validation will show only the values that are available for selection, as in the screen shot below.

This is the range which will identify which column of data from the table tblVal needs to be used as a dependency of the item in the cell to the left in the table tblData.
Let's look at a small section of our tblData

So, if we have selected Europe as the Region, we want to be shown a drop down list in column D under Countries of the countries that fall within Europe in the data validation table.
The formula which gives this range is
=INDEX(tblVal,0, MATCH(INDEX(tblData[@], COLUMN()-COLUMN(tblData)), tblVal[#Headers],0))
Let's dissect this to understand what it is doing. Index takes 2 parameters, firstly a row coordinate followed by a column coordinate.
=INDEX(tblVal,0
So, we are wanting to Index tblVal (which has the range $D$7:$R$18 on sheet Lists) and we have given it the first coordinate of 0. When the row coordinate is 0, index returns the whole column for the value provided by the column coordinate, so the result of this formula is going to be a whole column of values.
The column coordinate we are passing to Index, is a complicated Match function. What we want to find is the column name which has the same value as in the cell to the left of where our data validation formula is going to act. In this example, our data validation formula is going to be located in column D, and our dependent list will be based upon the value immediately to the left in column C, which is Europe
Finding the item we want to Match (Europe) is achieved by :-
INDEX(tblData[@], COLUMN()-COLUMN(tblData))
So COLUMN()-COLUMN(tblData) will give us the relative position of the column and will return a value of 4 -3 = 1
Overall, then
INDEX(tblData[@], COLUMN()-COLUMN(tblData))
Will be equivalent to =INDEX($C$7:$F$7,1) which will return the value Europe
So now, we have the value to use in our Match function, and where we are trying to match this value is in the header row of tblData In structured referencing,
tblVal[#Headers] returns the range of the header row of the table, which in this case would return the range Lists!$D$7:$R$7
[Note: whilst the construct Column(tblData) returns the column number of the first column of a table, the construct Row(tbldata) returns the row number of the first row of the Datatbody of the table, in this case 8, and not the Header row, which is row 7 ]
Our original _Mainlist formula thus is effectively INDEX(Lists!$D$7:$R$18,0,4) which as the first parameter is 0, will return us the whole of the column which is Lists!$G$7:$G$18
Before we move on to the next named range, take another look at the information above, and evaluate things as if you were in cell F6 of the small table above.
Stepping through the evaluation process here, you will see that
So this construct enables us to use structured referencing to give us the equivalent of the Volatile OFFSET function, and return a value which is one to the left =OFFSET($F$6,0,-1) which would also return Ontario
Our final named formula is the one that will be used for all data validation entries in our table tblData, apart from the first column which will use _Regions.
We have seen how _Mainlist returns us the column of data that we want from our validation table tblVal. We have also seen that it returns us the complete column within the table, whether it contains data or not.
In the example above, the return was Lists!$G$7:$G$18, but if we look at the table, we can see that cells G16:G18 are blank cells. Since one of the main purposes of Data Validation is to ensure that users can only enter data that is valid, we do not want to offer them blank cells as part of their selection.
The named range _Uselist takes the output from _MainList and returns a set of data that are just the cells that contain data.
It is just like the formula used for Regions by using
to give the first entry from the _MainList, and using
to provide the last cell reference that contains data.
So now we have a method of having any number of Dependent Data Validations using just three named formulae and Excel's Tables. The big advantage with Tables is they are automatically dynamic and will grow or shrink as we add more data to any of the rows.
Additionally, further dependencies can be added by adding more columns with a heading equivalent to one of the cell values in a prior dependency list, and there is nothing to add or alter to the formulae we have created.
The other tremendous advantage with Tables, is that they can be moved around at will anywhere within the workbook, without breaking any of the formulae. You don't have to ensure that you are in any specific cell within your data entry table when setting up the formulae to make it all work.
A workbook showing all of these features may be downloaded at the end of this page. To use this version, download the sample file with NO macros, below.
The final step is to set up Data Validation drop down lists in the main table.

To set up the drop down lists in the first column (Regions), follow these steps:
To set up the drop down lists in the remaining 3 columns, follow these steps:
After you set up the data validation drop down lists, test them, to make sure they're working correctly.

Get one of the following zipped sample workbooks --
In this section, you'll find related Excel tips, shortcuts, skills, and details. These things are nice to know, but not essential, so you can skip this section, and get back to work. Or dive in, for some extra Excel fun and knowledge!
--a) About the Developer
--b) Skills Spotlight
--c) Clear Cell Entries (Optional)
Here are the key Excel functions that I used for these examples.
Here are the key Excel functions that I used for these examples.
Since Data Validation is all about ensuring that the user only enters valid data into cells, the "wheels can come off the wagon" if the user goes through the Selection process and chooses, for example Americas > Canada > Ontario > Toronto and then goes back and changes Americas to Europe. Clearly, the values following Americas will all be incorrect, unless the user does go and make each of the changes.
If you can accept a little VBA in your workbook, then the .xlsm version as shown below includes the following piece of event code to clear entries on the same row, to the right of the changed value. As there may well be further data in the Table which is numeric data and should not alter even if the prior values change, we need to inform the code how far it should clear the data.
I have used a Variable called maxcols in the code below, which has been set to 6 for this example, but you will need to alter dependent upon your own situation. The code below has been copied onto sheet Data Entry
NOTE: This macro uses the SendKeys method
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim tr As Long, tc As Long, maxCols As Long
On Error GoTo exit_sub
tr = Target.Row: tc = Target.Column
'//// set the column number for the last column
'//// you want to be cleared automatically
'//// when an upstream cell is changed
'//// Often you will have other
'//// numeric data in a table which
'//// does not need to be cleared
'//// if other values are amended
maxCols = 6
'//// In this example, there are dependent validations
'//// in columnc to F so maxcols has been set to 6
If Target.Count > 1 Then GoTo exit_sub
If Not Intersect(Target, _
Me.ListObjects(1).Range) Is Nothing Then
'/// Assumes there is a single Table on this sheet,
'/// hence ListObjects(1) can be used,
'/// it does not have to be named.
'/// You can be specific and use the form
'/// If Not Intersect(Target, _
'/// Me.ListObjects("tblData").Range) Is Nothing Then
If tc = maxCols Then GoTo exit_sub
Application.EnableEvents = False
If tc < maxCols Then
Range(Cells(tr, tc + 1), _
Cells(tr, maxCols)).ClearContents
End If
'//// This next section checks whether
'//// the cell has had an entry made,
'//// and if so uses Sendkeys to automatically
'//// show the drop down list of possible entries,
'//// without having to click the drop down arrow.
If Target <> vbNullString Then
Target.Offset(0, 1).Select
If ActiveCell.Validation.Type = 3 Then
Application.SendKeys ("%{DOWN}")
End If
End If
End If
exit_sub:
Application.EnableEvents = True
End Sub
In addition to clearing entries ready for new values to be selected, the code checks to see if a new value has been entered into the cell (as opposed to just a deletion of value) and if so, it selects the cell one column to the right.
A check is then made to see if this newly selected cell contains Data Validation, and if so it produces the list of appropriate drop down values ready for the user to select, without the need for them to click the arrow in the cell first to produce the list. This can speed up data entry considerably.
About the Developer
|
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!
'-----------START OF TRANSCRIPT-----------------
In this video, you'll see how to set up drop down lists in Excel, where you can choose from a first drop down, and then the next one depends on what you've selected in that first one, and so on.
So now we're at the third one where we can only see items from Canada and a fourth level where we see cities for the Ontario region.
This is Debra Dalgleish from contextures.com, and I'll show you how to set this up.
This is the Data entry sheet, and I've got data validation set up here where we're choosing from these drop down lists.
There's another sheet called Lists. And on here, we have a big table with a column that shows our first drop downs, which are the regions.
So what we're going to create is a very flexible setup that will let you put in as much as you need to create these customized dependent drop down lists.
You've seen the completed workbook with the dependent drop downs and now you're going to see how to set it up from scratch.
So this is a new workbook.
I have two sheets, Data entry and Lists.
And on the data entry sheet, I just put the four column headings where we're going to select items from the drop down lists.
And, I'm just going to put a x right there just to create a a beginning for this row. I'll get rid of that later.
But we're going to change this to a named table.
And we'll come back to that later, but before I leave it, it got a default name of table one.
So that table is named.
And now we'll go to the Llist sheet where we're just getting started here too.
Now I'm going to pause for a minute and enter some data here.
Next, I'm going to turn this into a named table as well.
And there's our table and this will have all the values in it that we're going to use for the lists.
What we've done so far is set up a list of regions, which we'll be able to select from.
And then from one of those regions, you'll see a list of areas in that region.
If we go back to data entry, we're going to have a drop down here and we're ready now.
Based on what was selected here, we can show countries.
Now we can put some of the regions from the UK and some of the Canadian provinces.
So if you pick one of those, you'll have another list that you can select from.
And we'll take one more look at our data entry sheet.
And we'll make just a couple more columns in our values table with some cities.
I'm going to add headings that match what we've got in our list - so England and Ontario.
And so this table, we could keep expanding if we wanted details for any of these other items, but this will give us enough to set up our drop down lists.
Next, we're going to create three named ranges.
One will just be a list of these regions, and the other two will help us build a list based on our previous selection.
So these will create the dependent lists for our drop downs.
We're going to be creating dropdown lists on our other sheet.
And to do that, we're going to be referring to named ranges where the values are that we want to show in each list.
Our first list is going to be Regions and we could add more regions, but it's always going to be this column that the values will come from.
There are four values here, so it will start here and go down to the fourth row.
And now if I click down in this box, it highlights that list for me.
So we've set it up correctly. I'll click Close.
We've set up one named range _Regions, and we have two more to set up.
The next one is _MainList and it's going to give us a column out of this table of all our items that we've created.
I'm going back to the data entry sheet and I've just typed some values in here, a region and a country from that region. So we can see how this formula is going to work.
To find that number of the column, we have to look for something in the headers, and we're going to use INDEX to find out where we are in this table, which is called tblData
So here, INDEX(tblData, this means the entire row.
So if I'm here, I'm in column four, starts in two, which means look in the second column.
But for now, we wanna find the entire column based on whatever we selected in the cell to the left.
And there's our main list.
So that's doing what we need it to do.
Now we'll create a third named range and this one will be used for the dropdown lists.
We're going to call this _UseList and it is going to be based on the one we just created called main list.
Here's the formula that we're going to use.
So we'll INDEX the _MainList, starting from the first row and cell down to in that main list to a count of items in the main list.
So if I'm in this area cell for Americas, Canada and go to the name manager and click _UseList.
It shows the list of the Canadian provinces.
The final step is to set up the dropdown lists.
We're going to have one drop down for the regions and then a different drop down for all the other columns.
And now you can select a region in each of those rows.
I'm going to choose Europe and Americas.
Now we're going to set up the drop downs that are dependent on the previous cell in all of the other columns.
So now, if I have selected Europe, the countries show Europe.
If I press tab to start a new row and then:
For more Excel tips and tutorials and to download the sample file for this video, please visit my website at www.contextures.com.
'-----------END OF TRANSCRIPT-----------------
Dependent Drop Down Setup Choices
Dependent Drop Downs, Advanced
Dependent Dropdowns from a Sorted List
Last updated: February 16, 2026 3:26 PM