TOP

Linked drop-down lists

YouLibreCalc for Excel logo

Description

In Excel you can quickly and easily create a dropdown list , but have you ever tried creating a dependent dropdown list? There are several ways to create such a list, so let's take a look at them.


Method 1. INDIRECT function

This technique is based on the application of the INDIRECT function, which can do one simple thing - convert the contents of any specified cell into a range address that Excel understands. That is, if the cell contains the text " А1 ", then the function will give a reference to the cell as a result А1 . If the cell contains the word " Auto ", then the function will output a reference to the named range with the name Auto etc.

Take, for example, this list of car models Toyota, Ford and Nissan :

Select the entire list of Toyota models (from cell А2 and down to the end of the list) and give this range a name Toyota in the menu Insert - Name - Assign (Insert - Name - Define) . Then we will repeat the same with the lists Ford and Nissan , specifying the names of the ranges accordingly Ford and Nissan .

When assigning names, remember that the names of the ranges in Excel must not contain spaces, punctuation marks, and must begin with a letter. Therefore, if there was a gap in one of the car brands (for example Ssang Yong), then it would have to be replaced in the cell and in the name of the range with an underscore (ie Ssang_Yong).

Now let's create the first drop-down list for choosing a car brand. Select an empty cell and open the menu Data - Check (Data - Validation) , then from the drop-down list Data type select an option List and in the field Source - highlight cells with brand names (yellow cells in our example). After clicking on ОК the first drop-down list is ready:

Now let's create a second drop-down list, which will display the models of the brand selected in the first list. Just like in the previous case, select an empty cell and open the menu Data - Check - further List . In the field Source you will need to enter the following formula:

=INDIRECT(F3)

Where:

All. After clicking on OK the contents of the second list will be selected by the name of the range selected in the first list.

Cons of this method:

Method 2. Match list (OFFSET and MATCH)

This method requires a sorted list of make-model matches of the following type:

To create a primary drop-down list of brands, you can use the usual method described above, that is:

But for a dependent list of models, you will have to create a named range with the function OFFSET, which will dynamically refer only to cells of models of a certain brand. For this:

=OFFSET( $A$1 ; MATCH($G$7;$A:$A;0)-1 ; 1 ; COUNTIF($A:$A;$G$7) ; 1 )

References must be absolute (with signs $ ). After pressing Enter, sheet names will be automatically added to the formula.

The function OFFSET is able to issue a reference to a range of the desired size, shifted relative to the initial cell by the given number of rows and columns. In a more understandable version, the syntax of this function is as follows:

=OFFSET( start_cell ; shift_down ; shift_right ; range_size_in_rows ; range_size_in_columns )

So:

The result should be something like this:

It remains to add a drop-down list based on the created formula to the cell G8 . For this:

Related Articles: