Excel create a list based on criteria

Excel create a list based on criteria

Validation > Drop Downs > Dependent

Easy steps for Excel dependent drop down list. Conditional data validation based on other cell, like Region and City lists. Videos, written steps, get free Excel file.

What Is a Dependent Drop Down List?

In an Excel dependent drop down list, the list of items changes, depending on the value in another cell.

For example:

  • Fruit was selected as Produce Type in cell B3, and the drop down showed the Fruit list in cell D3
  • Next, in cell B4, Vegetable was selected as Produce Type. In cell C4, the dependent dropdowns changed automatically, and now it shows the Vegetable list

There are setup instructions and a video in the sections below.

Excel create a list based on criteria

Video: Dependent Drop Down Lists

In this short video, you'll see how to set up a main drop down list, with a dependent drop down list in the next column. The written instructions are below the video, and the full transcript is on the Dependent DropDown Lists Video page.

Get Started: Dependent Drop Down Lists

Here are the step-by-step instructions for making dependent drop down lists in Excel. This example uses Fruit and Vegetable lists.

In the screen shot below, you can see the completed data entry sheet.

  • Select a produce type (fruit or vegetable) in column B, from the first drop-down list
  • Then, in column C, a dependent drop down list show items for the selected product type only.

Excel create a list based on criteria

There are a few steps for setting up the drop down lists, and the details are in the sections below.

Set Up the Worksheets

This example will have a workbook with two sheets -- a data entry sheet, and a sheet with lists.

  1. Create a new workbook
  2. Change the name for Sheet1 to "DataEntry"
  3. Insert a new sheet in the workbook, and name that sheet "Lists"

Excel create a list based on criteria

Create Lists

Next, you'll create lists with items for the drop down lists.

In this example, you'll set up 3 lists. The main list has produce types, and the other two lists have items for the dependent drop downs.

To create each list, you'll do three things:

  1. Type the items on the Lists sheet
  2. Format the lists as an Excel table
  3. Name the lists.

1. Type the Lists

To type the lists, go to the Lists sheet. Start with the main list - Produce types.

  1. In cell B2, type the main list heading, Produce List
  2. In cells B3 and B4, type Fruit and Vegetable.

NOTE: The Produce list has one-word items in it -- Fruit and Vegetable. This is important, because those words will be used as Excel names, and two-word names are not allowed as names. If you need to use multiple-word items in the main list, see: Using Two Word Items

Add the Dependent Lists

Next, type the dependent lists, with the headings Fruit List (in cell D2) and Vegetable List (in cell F2). These lists can contain one-word items (apple), or multiple-word items (green beans).

Excel create a list based on criteria

2. Format Lists as Tables

Next, follow these steps, to format each list as an Excel Table. This makes your list dynamic -- the list size will adjust automatically if you add or remove items, so your drop down will show the entire list.

Follow these steps for each of the 3 lists:

  1. Select a cell in the list, and on the Home tab, click Format as Table
  2. Excel create a list based on criteria

  3. Click on one of the Table Styles
  4. Add a check mark for My table has headers
  5. Click OK

    Excel create a list based on criteria

Here is the Lists sheet, with all 3 lists formatted as Excel Tables

Excel create a list based on criteria

Create a Named Range

Next, follow these steps to create a named range for each formatted Excel Table.. Later, you will use this name, when making the drop down lists on the Data Entry sheet.

Name the Produce List
  1. Select the items in the Produce table (cells B3:B4), but not the table heading.
  2. Click in the Name box, to the left of the formula bar
  3. Type a one-word name for the list -- Produce
  4. Press the Enter key, to complete the name.
  5. Excel create a list based on criteria

Name the Fruit and Vegetable Lists

Next, follow these steps to name the fruit and vegetable lists.

  1. Select the fruit names in cells D3:D6
  2. Click in the Name box, to the left of the formula bar
  3. Type a one-word name for the list -- Fruit.
  4. Press the Enter key, to complete the name.
  5. Excel create a list based on criteria

  6. Select the vegetable names in cells F3:F6.
  7. Click in the Name box, to the left of the formula bar
  8. Type a one-word name for the list -- Vegetable.
  9. Excel create a list based on criteria

  10. Press the Enter key, to complete the name.

Add the Main Drop Down

Next, you'll add the main drop down (Produce Type) on the DataEntry sheet. This is just a normal data validation drop down list.

Start the Data Entry Sheet

First, you'll enter headings on the data entry sheet, and set up a named table.

  1. On the DataEntry sheet, type the headings in B2:C2 -- ProductType and Item
  2. Select cell B2, and and on the Home tab, click Format as Table
  3. Click on one of the Table Styles
  4. Add a check mark for My table has headers
  5. Click OK

Excel create a list based on criteria

Add the Main Drop Down

Next, you'll the main drop down list, in the Produce Type column

  1. On the DataEntry sheet, select cell B3
  2. On the Ribbon, click the Data tab, then click Data Validation.
  3. From the Allow drop-down list, choose List
  4. In the Source box, type an equal sign and the list name: =Produce
  5. Excel create a list based on criteria

  6. Click OK, to complete the data validation setup.
  7. To test the drop down, click the arrow in cell B3, and select Fruit from the list

Excel create a list based on criteria

Add the Dependent Drop Down

Next, you'll create a dependent drop down list in the Item column. This cell will have a formula to create the data validation drop down list. Read more about the INDIRECT function here.

  1. On the DataEntry sheet, select cell C3
  2. On the Ribbon, click the Data tab, then click Data Validation..
  3. From the Allow drop-down list, choose List
  4. In the Source box, type an equal sign and INDIRECT function, referring to the first data cell in the Produce Type column:
    In this example, cell C3 is active, so the formula will refer to the Product Type cell in row 3: =INDIRECT(B3)
    Note: If you click on cell B3, Excel will add an absolute reference -- $B$3. Remove the $ signs, becuse we need a relative reference in this formula
  5. Click OK.

Excel create a list based on criteria

Note: If cell B3 is empty, you'll see the message shown below. Click Yes to continue.

Excel create a list based on criteria

Test the Drop Down Lists

To test the dependent drop down lists, follow these steps

  1. Fruit should be selected in cell B3 -- if not, select it now.
  2. Select cell C3, then click the arrow, and select one of the fruit items from the list

    Excel create a list based on criteria

  3. Then, press the Tab key, to start a new row in the data entry table.
  4. In the Produce Type column, select Vegetable from the Produce drop down list.
  5. Move to the Item column, in the same row.
  6. In the Item column, click the drop down arrow, and select an item from the Vegetable list

Excel create a list based on criteria

NOTE: If a Produce Type has not been selected, the Item drop down in that row will not work.

Advanced Dependent Drop Downs

The instructions in the previous sections show how to set up a basic dependent drop down list. Here are a few advanced examples.

Use Two-Word Items

In some workbooks, you might need to have two-word items in the first Excel data validation drop-down list. For example, your choices are 'Red Fruit', 'Green Fruit' and 'Yellow Fruit'

  1. Create the first named range and dropdown list as described above.
  2. Create the supporting named lists, using one-word names, e.g. RedFruit, GreenFruit, YellowFruit
  3. For the second dropdown, choose to Allow: List, and use a formula that removes the spaces from the names. For example:

  =INDIRECT(SUBSTITUTE(A2," ",""))

Excel create a list based on criteria

Main Items with Illegal Characters

You may need items in the first Excel data validation drop-down list that contain characters not allowed in range names, such as the ampersand (&).

Excel create a list based on criteria

For example, your choices are 'Red Fruit', 'Green Fruit' and 'Yellow & Orange Fruit'. For the dependent lists, you can create ranges with one-word names, such as YOFruit. Then, create a lookup table, which lists each item in the first Excel data validation drop-down list, and the range where its dependent items will be stored.

To start, create the item lists and the first Excel data validation drop-down:

  1. Create the first named range and drop-down list as described above. In this example, the range is named ProductList, with values in cells A6:A8. The drop-down list in cell A2 uses ProductList as its source.
  2. Create the dependent lists, and name them, using one-word names, with "List" at the end, e.g. RedFruitList, GreenFruitList, YOFruitList. In this example, RedFruitList is in A11:A12, YOFruitList is in A15:A16 and GreenFruitList is in A19:20.
  3. Select an item from the drop-down list in cell A2.

Next, you'll create the lookup table, to match each item with its dependent items' range name.

  1. In the column to the right of the FruitList range, enter the code name for each item's dependent list. For example, YOFruit is entered as the code name for Yellow & Orange Fruit.
  2. Name the lookup table. In this example, the range A6:B8 is named ProductLookup.
  3. Select cell B2, and from the Data menu, choose Validation.
  4. Choose to Allow: List.
  5. For the Source, enter a formula that uses a VLookup formula to find the dependent list's range name -- a combination of the code name and "List".
    For example:   =INDIRECT(VLOOKUP(A2, ProductLookup,2,0) &"List")

With Red Fruit selected in cell A2, the VLookup formula will return RedFruitList as the range name for the dependent list. The RedFruitList items will be displayed in cell B2's drop-down.

Excel create a list based on criteria

To create a 3rd dependent drop down list, use the same techniques, to create lookup tables and items lists.

Excel create a list based on criteria

In the screen shot below, there are lookup tables named RedFruitLookup, YOFruitLookup and GreenFruitLookup. Items lists, with the code names and "List", have been added to the worksheet.

Excel create a list based on criteria

In the data validation window, use this formula for the 3rd drop down:

=INDIRECT(VLOOKUP(B2, INDIRECT(VLOOKUP(A2, ProductLookup,2,0)&"Lookup"),2,0) &"List")

The formula finds the lookup table based on the product type selected in cell A2, e.g. RedFruitLook, and gets the code for the selected product -- Mac. It adds "List" to the code, and shows the items in the MacList range.

Excel create a list based on criteria

Add a Third Dependent Drop Down

If you need to, you can add another set of dependent data validation dropdown lists that depend on the selections in the first two dropdowns. select a country and region, then select a city in the selected country and region.

Note that the region names are not unique -- there is a West region in both Canada and the USA -- so we can't show a City list that is only based on the region names.

To make sure that the correct list of cities appears, the city lists will be named for the country and region. There are 2 countries, and each country has 3 regions, so we will set up 6 named ranges for the 3rd level drop down lists.

NOTE: If you need more than a few named ranges for your 3rd level lists, try the Dependent Lists with Tables technique instead -- it will be easier to set up and maintain.

Excel create a list based on criteria

To set up 3-level dependent lists:

  1. Create the main named ranges - Country, Canada and USA, as described above.
  2. Excel create a list based on criteria

  3. Create another set of named ranges, naming them for the available combinations in the first two lists. For example, create ranges named CanadaWest and USAWest.

    Excel create a list based on criteria

  4. On the data entry sheet, set up drop down lists in the Country and Region columns.
  5. For the City dropdown, add data validation, and choose to Allow: List
  6. For the source, use a formula that combines the entries in the first two columns.
    For example, in cell D2, the data validation formula uses INDIRECT and SUBSTITUTE, to combine the values in B2 and C2, and remove any space characters:
  7.   =INDIRECT(SUBSTITUTE(B2&C2," ",""))

    Excel create a list based on criteria

Use Dynamic Lists

Because the INDIRECT function only works with references, not formulas, the previous method for dependent data validation won't work with lists that use formula-based dynamic named ranges, such as OFFSET ranges. Use one of the following solutions when a dynamic list is required:

Named Excel Tables

To avoid the problem, use named Excel tables, instead of formula-based dynamic ranges.

  • Create a table with your list items
  • Select all the items in the table column (not the heading)
  • Click in the Name Box, type a one-word name the range, and press Enter

Then, use one of the INDIRECT function examples shown above, to create a dependent drop down list.

Dynamic Name Workaround

If you can't use the Named Excel Tables, use the following method for creating dependent lists from formula-based dynamic named ranges:

  1. Create the first named range and dropdown list as described above.
  2. Create the supporting named lists, and name the first cell in each range, e.g. cell B1 is named Fruit and cell C1 is named Vegetables.

    Excel create a list based on criteria

  3. Name the column in which each list is located, e.g. column B is named FruitCol and column C is named VegetablesCol
  4. For the second dropdown, choose to Allow: List, and use a formula that calculates the lookup range. For example, if the first dropdown list is in cell E2:

=OFFSET(INDIRECT($E2),0,0, COUNTA(INDIRECT(E2&"Col")),1)

if two-word items will be used, you can include the SUBSTITUTE function in the formula:

=OFFSET(INDIRECT(SUBSTITUTE($F2," ","")),0,0, COUNTA(INDIRECT(SUBSTITUTE($F2, " ","") &"Col")),1)

Dependent Drop Down With IF Formula

This is another example of dependent drop down lists in Excel, with the IF function used with INDIRECT, for a more flexible drop down. In this example:

  • If a country is selected in column A, only the cities from that country are in dependent drop down list
  • If NO country is selected in column A, a list of world countries is shown in the dependent drop down

Excel create a list based on criteria

This video shows the basic set up steps, and then shows how to use the Excel IF function with a dependent drop down. There are written steps below the video, and you can download the sample file below.

Select Countries and Cities

In this example, there’s a drop down to select a country in column A. If you select USA as the country, cities from the USA appear in the dependent drop down in Column B.

Excel create a list based on criteria

There are city lists in the workbook, and each list is named to match its country name.

  • USA: cells C2:C5
  • Canada: cells E2:E4

Excel create a list based on criteria

Simple Dependent Drop Down Formula

Originally, there was a simple formula for the data validation list in column B:

=INDIRECT(A2)

Excel create a list based on criteria

So, if you selected USA in cell A2, dependent drop down list shows cities from the range named USA.

Excel create a list based on criteria

No Country Selected

With that simple INDIRECT formula, the drop down list in column B does NOT work, if no country is selected in column A.

  • When you click on the drop down arrow in cell B3, nothing happens.
  • Because cell A3 is empty, the INDIRECT formula returns an error, so the drop down does not function.

Excel create a list based on criteria

Add IF Function to Formula

Instead of a drop down arrow that doesn't work, we'll change the dependent drop down formula, and add the IF function. The revised formula will give users the option to select a World city, if they haven’t selected a country in column A.

On the Lists worksheet, there’s another range, named World, highlighted in the screen shot below.

Excel create a list based on criteria

Just as you can use the IF function on the worksheet, you can use it in a data validation formula.

For the dependent drop down cells in column B, we’ll change the formula to the following:

  • =IF(A2="",World,INDIRECT(A2))

After this change to the data validation formula, if you click on a drop down arrow in column B, and no country is selected in column A, the list of world cities appears.

Excel create a list based on criteria

How the IF Formula Works

Here's what the revised formula does:

  • First, the IF function checks the cell in column A, to see if it is blank -- equal to an empty string ""
  • IF the cell is blank, the data validation drop down will show the list from the range named World
  • Otherwise, show the list named for the country selected in cell A2, using the INDIRECT function

Excel create a list based on criteria

Show Long or Short Drop Down List

With this dependent drop down technique, from AlexJ, you can see a full list of customers in a drop down list. Or, switch to a short list, with just your top customers. The technique is driven by a formula -- no macros required.

This short video shows the steps, and there are written steps below the video.

Set Up the Lists

The first step is to create two named lists -- they will be used as the source for the drop down lists.

  1. Type the full list of customers
  2. Select all the cells in that list, and name the range: FullList
  3. In another column, type "Full List" in row 2.
  4. Starting in row 3, type the short list of top customers
  5. Select all the cells in that list, including the "Full List" cell
  6. Name that range: ShortList

Excel create a list based on criteria

Create the Drop Down List

Next, you'll create the drop down list, by using data validation with an IF formula:

  1. Select the cell(s) where you want the drop down list of customers
  2. On the Ribbon, click the Data tab, then click Data Validation
  3. In the Data Validation dialog box, on the Settings tab, under Allow, select List
  4. In the Source box, type an IF formula that refers to the active cell, and the named lists.
    • If you're using the list in a single cell, use an absolute reference
      • =IF($E$3="Full List", FullList, ShortList)
    • For multiple cells, use a relative reference
      • =IF(E3="Full List", FullList, ShortList)
  5. Click OK, to close the dialog box.

Excel create a list based on criteria

Use the Drop Down List

Select the cell with the data validation list, and click the drop down arrow.

If the cell does not contain the text "Full List", the drop down will show the short list of top customers.

Excel create a list based on criteria

If you need to see the full list, select "Full List" from the top of the drop down list, and then click the drop down arrow again.

Excel create a list based on criteria

Prevent Invalid Selections

After someone selects an item from a dependent drop down, they could go back to the main drop down, and select a different item. That could result in mismatched items in that row.

For example, Fruit could be selected from the main drop down, and then Lemon in the dependent drop down. If Fruit is changed to Vegetable later, the Lemon selection would be incorrect -- it's not a vegetable.

To prevent invalid selections, here are a couple of techniques that you can use

Block Changes in First Drop Down

To block changes to the first list, you can change the data validation formula, so the list does not appear unless the second cell is empty. This video shows you how this technique works, and written instructions are below the video.

Block Changes in First Drop Down

With dependent drop down lists, problems can occur, if someone goes back to the first list, and changes it. Then, the first and second selections are mismatched -- for example, in the screen shot below, Vegetable is the first choice, and Banana is selected in the second column.

To block changes to the first list, you can change the data validation formula, so the list doesn't work unless the second cell is empty.

Excel create a list based on criteria

Instead of just referring to the Produce range for the Produce Type drop down, the formula will check for an entry in the Item column.

  • If the Item cell is blank, the Produce Type drop down will show the Produce list
  • If an item has been selected, the drop down will try to show the range created by the INDIRECT function -- "FakeRange". Because there is no range with that name, the result is an error, and the drop down will not work.

To change the formula:

  1. Select the data validation cells in the first column
  2. On the Ribbon's Data tab, click Data Validation
  3. For Allow, select List
  4. In the Formula box, type:
  5. =IF(C2="",Produce, INDIRECT("FakeRange"))

  6. Click OK

Now, the drop down in the first column won't work if the Item has been selected in that row.

Clear Dependent Cell After Selecting

In the previous section, the data validation formula was designed to prevent selections from the first drop down, if the cell to the right contained data.

Another option is to use a macro, to clear the dependent cell, after making a selecting in the first drop down. That will prevent mismatched selections.

In this example, column B contains a drop down list of Regions. After you select a Region, the drop down list in column C shows the customers in the selected region.

Excel create a list based on criteria

Go back and select a different region, and the existing customer name will be cleared.

Excel create a list based on criteria

Add Event Code to Clear the Customer Cell

When you select a Region, event code clears the cell to the right. To add the code, right-click the sheet tab, and click View Code.

Paste the following code onto the sheet module. You might need to change the column number, to match the column number on your worksheet.

NOTE: The sample workbook also has code for clearing multiple dependent cells.

Private Sub Worksheet_Change
_(ByVal Target As Range) On Error Resume Next If Target.Column = 2 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

Download Sample Files

NOTE: There are other techniques for setting up dependent drop down lists, so see which setup method might be best for your needs.

More Tutorials

Data Validation Basics

Data Validation Index Page

Change Product Name to Code

Dependent Drop Down Setup Choices

Dependent Drop Down from Dynamic Arrays

Dependent Drop Down Lists Video

Dependent Dropdowns from a Sorted List

Dependent Lists With INDEX

Hide Previously Used Items in a Dropdown List

Use a Data Validation List from Another Workbook

Data Validation Criteria Examples

Data Validation Tips

Data Validation With Combo Box