Smart Dependent DropDown Lists in Excel:
Expandable & Excluding Blank Cells
In situations where the contents of a dropdown list are frequently changing, it’s helpful to have a dynamic dropdown list that can automatically expand, as well as exclude any blank cells in the cell references.
This example uses the sample data of App names for three divisions: Productivity, Games, and Utility.
Adding data validation for Division
Method 1: Using OFFSET() to create a dynamic dropdown list
Setup formula for the data validation
Whenever a formula is to be used as a data validation criteria, it is usually easier to first set the formula up on the spreadsheet, then transfer it to the data validation window so that all the Excel helper tips show up as guides.
The OFFSET() formula has the syntax:
= OFFSET(reference, rows, cols, [height], [width])
 reference = starting point, $A$4
 rows = how many rows going down until the first value to be used. In this case, since we want to start one row below the header, we input 1
 cols = how many columns to the right until the first value to be used. In this case, this is dependent on the selected Division by the user. A MATCH() formula comes in handy since it returns a number:
MATCH(lookup_value), lookup_array, [match_type])

 lookup_value = source, $F$4
 lookup_array = where the lookup will be done, $A$4:$C$4
 match_type = 0 for exact match
It now becomes: MATCH($F$4,$A$4:$C$4,0)
However, this can’t be used as is since the return value of the MATCH() function will be 1, 2, or 3 depending on the selected division.
What this means is that when the Productivity division is selected, the MATCH() function returns a “1”, which tells the OFFSET() function to move one column to the right instead of staying in column A.
To fix this, a correction is made by deducting 1 from the MATCH() function.
The col parameter now becomes:
MATCH($F$4,$A$4:$C$4,0)1
 [height] = how many rows will be included. This should correspond to the number of apps listed for each division and be dynamic to expand and contract. The COUNTA() function comes in handy since it counts cells with numbers or text.
COUNTA(value1, [value2], …)
However, since the cell reference changes depending on the division selected by the user, another function should be introduced.
The OFFSET() function can also be used here.
OFFSET(reference, rows, cols, [height], [width])

 reference = starting point, $A$4
 rows = how many rows going down until the first value, 1
 cols = how many rows to the right until the first value to be used. This will again depend on the division selected. The same MATCH() function will be used here:
MATCH($F$4,$A$4:$C$4,0)1

 [height] = how many rows will be displayed. Use a bigger height than what is expected to make sure additional cells are taken account of. An arbitrary number 20 is used for this example, which should be sufficient. This value can be changed later on.

 [width] = how many columns will be included, 1
This now becomes:
COUNTA(OFFSET($A$4, 1, MATCH($F$4, $A$4:$C$4,0)1, 20, 1))
 [width] = how many columns will be included. Since we only need one column, set this as 1.
The final formula now becomes:
=OFFSET($A$4, 1, MATCH($F$4, $A$4:$C$4,0)1, COUNTA(OFFSET($A$4, 1, MATCH($F$4, $A$4:$C$4,0)1, 20, 1)),1,)
A single value will be displayed in the cell.
However, the formula actually returns an array and is unable to display all the values on a single cell.
To view the entire array, click inside the formula bar and press F9.
Press CTRL + Z again to undo.
Adding data validation for App names
Copy the entire formula.
Add data validation criteria to cell F5 through Data > Data validation.
Under validation criteria, select List.
Paste the formula to the source text box.
Method 2: Using table referencing to create a dynamic dropdown list
Convert data table into Excel tables
Instead of converting the entire data table as one Excel table, convert it into 3 Excel tables.
To do this, highlight each data column (CTRL + SHIFT + DOWN when selecting the header).
Press CTRL + T.
Double check if the cell referencing is correct.
Tick the box to indicate that the table has headers.
Change the table name to the division name.
In this example, we use TableProd.
Do the same for the Games and Utility columns and rename them to TableGame and TableUtility.
Setup formula for data validation criteria
The INDEX() formula can be used to make sure the correct Table is used as reference.
There are two syntax options for INDEX().
The second option will be used.
INDEX(reference, row_num, [column_num], [area_num])
 reference = instead of selecting an array of cells, the tables should be selected. To do this, hover over the header until a black arrow shows up.
Selecting it should now display the table name with the column name in square brackets: TableProd[Productivity].
Select the other 2 columns in the same manner and enclose all 3 in parenthesis.
This now becomes:
(TableProd[Productivity],TableGame[Games], TableUtility[Utility])
 row_num = how many rows going down will be included. Since all rows should be included, skip this argument by using a comma.
 [column_num] = how many columns will be included. Since there is only one column for each table, there is no need to specify the column number. Skip this argument by using a comma.
 [area_num] = how many areas to move. This can be dictated by a MATCH() formula.
MATCH($F$4,$A$4:$C$4,0)
The final formula now becomes:
=INDEX((TableProd[Productivity],TableGame[Games],TableUtility[Utility]),,,MATCH($F$4,$A$4:$C$4,0))
Similar to method 1, a single value will be displayed on the cell.
However, the formula actually returns an array.
To view the entire array, click inside the formula bar and press F9.
Adding data validation for App names
Copy the entire formula.
Add data validation criteria to cell F5 through Data > Data validation.
Under validation criteria, select List.
Paste the formula to the source text box.
You might receive a message box indicating a problem with the formula.
This is because data validation is unable to use this type of table referencing.
To remedy this, paste this formula in Name Manager.
This is found under Formulas > Name Manager.
The Name Manager will pop up and display the three tables.
Click on New.
Give the formula a new name and paste the formula in the last text box.
It should now show up on the list.
Go back to Data Validation.
Under validation criteria, select List.
For the source, write the name of the formula.
If you have forgotten the name of the formula you have recently added to Name Manager, press F3.
If set up correctly, it should now display the App Names in the dropdown list.
The new Excel Dashboards course is here!
Visually Effective Excel Dashboards for your reports.
Redeem your coupon for 75% off below.
Leave A Comment