Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to filter data from drop down list selection in Excel?

In Excel, most of us may filter data by using the Filter feature. But, have you ever tried to filter data from the drop down list selection? For example, when I select one item from the drop down list, I want its corresponding rows will be filtered out as following screenshot shown. This article, I will talk about how to filter data by using drop down list in one or two worksheets.

Filter data from drop down list selection in one worksheet with helper formulas

Filter data from drop down list selection in two worksheets with VBA code


Filter data by multiple criteria or other specific condition, such as by text length, by case sensitive, etc.

Kutools for Excel’s Super Filter feature is a powerful utility, you can apply this feature to finish the following operations:

  • Filter data with multiple criteria;              Filter data by text length;
  • Filter data by upper / lower case;             Filter date by year / month / Day / week / quarter

doc-super-filter1

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Filter data from drop down list selection in one worksheet with helper formulas


To filter data from drop down list, you can create some helper formula columns, please do with the following steps one by one:

1. First, insert the drop down list. Click a cell where you want to insert the drop down list, then click Data > Data Validation > Data Validation, see screenshot:

2. In the popped out Data Validation dialog box, under the Settings tab, select List from the Allow drop down, and then click button to choose the data list you want to create the drop down list based on, see screenshot:

3. And then click OK button, the drop down list is inserted at once, and choose one item from the drop down list, then enter this formula: =ROWS($A$2:A2) (A2 is the first cell within the column which contains the drop down list value) into cell D2, and then drag the fill handle down to the cells to apply this formula, see screenshot:

4. Go on entering this formula: =IF(A2=$H$2,D2,"") into cell E2, and then drag the fill handle down to fill this formula, see screenshot:

Note: In the above formula:A2 is the first cell within the column which contains the drop down list value,H2 is the cell where drop down list placed, D2 is the first helper column formula.

5. And then type this formula: =IFERROR(SMALL($E$2:$E$17,D2),"") into cell F2, then drag the fill handle down to the cells to fill this formula, see screenshot:

Note: In the above formula: E2:E17 is the second helper formula cells, D2 is the first cell in first helper formula column.

6. After inserting the helper formula columns, then you should output the filtered result into another location, please apply this formula: =IFERROR(INDEX($A$2:$C$17,$F2,COLUMNS($J$2:J2)),"") into cell J2, and then drag the fill handle from J2 to L2, and the first record of the data based on the drop down list has been extracted, see screenshot:

Note: In the above formula: A2:C17 is the original data you want to filter, F2 is the third helper formula column, J2 is the cell where you want to output the filter result.

7. And then go on dragging the fill handle down to the cells to display all corresponding filtered records, see screenshot:

8. From now on, when you select one item from the drop down list, all rows based on this selection are filtered at once, see screenshot:


Filter data from drop down list selection in two worksheets with VBA code

If your drop down list cell in Sheet1, and the filtered data in Sheet2, when choosing one item from the drop down list, another sheet will be filtered out. How could you finish this job in Excel?

The following VBA code may do you a favor, please do as this:

1. Right click the sheet tab which contains the drop down list cell, and then choose View Code from the context menu, in the opened Microsoft Visual Basic for applications window, copy and paste the following code into the blank Module:

VBA code: Filter data from drop down list selection in two sheets:

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice
    On Error Resume Next
    If Not Intersect(Range("A2"), Target) Is Nothing Then
        Application.EnableEvents = False
        If Range("A2").Value = "" Then
            Worksheets("Sheet2").ShowAllData
        Else
            Worksheets("Sheet2").Range("A2").AutoFilter 1, Range("A2").Value
        End If
        Application.EnableEvents = True
    End If
End Sub

Note: In the above code: A2 is the cell which contains the drop down list, and Sheet2 is the worksheet contains the data you want to filter. The number 1 in the script: AutoFilter 1 is the column number that you want to filter based on. You can change them to your need.

2. From now on, when you select one item from the drop down list in Sheet1, and the corresponding data will be filtered out in Sheet2, see screenshot:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Aleks · 29 days ago
    For me, the Formula =ROWS($A$2:A2) didn't workend! It always gave me "2" back. I had to put =ROWS($A2:A2), so without the second "$", in order to reproduce your result.
  • To post as a guest, your comment is unpublished.
    kev · 1 years ago
    How do I add multiple drown down menus? For example,
    If i wanted a drop down menu for Product and name?.
    • To post as a guest, your comment is unpublished.
      Jim · 1 years ago
      Hey Kev, wondering if you found an answer to your question here? I have been looking for a bit to no avail.