Creating a Drop-Down Filter to Extract Data Based on a Selection in Excel – 4 Methods

This is the sample dataset:

creating a drop down filter to extract data based on selection


Method 1 – Create a Drop-Down Filter to Extract Data Based on Selection with Helper Columns in Excel

Insert 3 helper columns.

STEPS:

=ROWS($B$5:B5)

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • Press Enter and use the Fill Handle to complete the series.

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • Select G5 to create the drop-down filter.
  • Select Data Data Tools Data Validation.

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • In the Data Validation dialog box, choose Settings.
  • Select List in Allow.
  • Enter TV, AC in the Source box.

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • Click OK.

The filter is created.

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • Select E5 and enter the formula:
=IF(B5=$G$5,D5,"")
  • Press Enter.

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • Drag down the Fill Handle to see the result in the rest of the cells.
  • Select F5. Use the formula:
=IFERROR(SMALL($E$5:$E$10,D5),"")
  • Press Enter.

Create a Drop Down Filter to Extract Data Based on Selection with Helper Columns in Excel

  • Drag down the Fill Handle to see the result in the rest of the cells.
  • Select I5 and enter the formula:
=IFERROR(INDEX($A$5:$C$10,$F5,COLUMNS($I$5:I5)),"")
  • Press Enter.

The COLUMNS function returns the number of columns in $I$5:I5. The INDEX function returns the cell reference or cell value at the intersection of the row number  in F5 and the column number in I5. The IFERROR function returns blank cells if an error is found.

  • Drag down the Fill Handle to see the result in the rest of the cells.

This is the output.

  • Choose AC from the drop-down filter, The dataset will automatically update.

Read More: How to Make Multiple Selection from Drop Down List in Excel


Method 2 – Using the FILTER Function to Create a Drop-Down Filter and Extract Data Based on the Selection

STEPS:

  • Select A4:C10.
  • In the Insert tab, select Table.

Excel FILTER Function for Creating a Drop Down Filter to Pull Data Based on Selection

  • In the dialog box, click OK.

Table1 is created.

  • Open a blank sheet and select B2. Enter the formula:
=UNIQUE(Table1[Product])

Excel FILTER Function for Creating a Drop Down Filter to Pull Data Based on Selection

  • Click OK.

Unique product names are displayed.

Excel FILTER Function for Creating a Drop Down Filter to Pull Data Based on Selection

  • Select E5 in the main sheet.
  • Go to Data Data Tools Data Validation.

Excel FILTER Function for Creating a Drop Down Filter to Pull Data Based on Selection

  • In the dialog box, choose Settings.
  • Select List in Allow.
  • In the Source box, enter the formula:
=list!$B$2#

list is the new sheet name. The formula will look for the value in B2 in the list sheet.

  • Select G5. Use the formula:
=FILTER(Table1,Table1[Product]=E5)
  • Press Enter.

The FILTER function filters Table1 and returns the dataset that matches E5.

  • Change the drop-down filter to AC to see the output.

Read More: Create a Searchable Drop Down List in Excel


Method 3 – Extract Data Based on a Selection by Creating a Drop Down Filter with the INDIRECT Function

To extract the Total Sales based on a selection:

Extract Data Based on Selection by Creating a Drop Down Filter with Excel INDIRECT Function

STEPS:

  • Select C4 in the sheet you want to place the extracted data.

Extract Data Based on Selection by Creating a Drop Down Filter with Excel INDIRECT Function

  • Select Data Data Tools Data Validation.
  • In the dialog box, select List in Allow.
  • In the Source box, enter the formula:
=$C$8:$C$9

  • Click OK.
  • Select C6 and use the formula:
=INDIRECT("'"&C4&"'!C11")
  • Press Enter.

The Total Sales in the selected sheet are displayed in C4.

  • Change the sheet using the drop-down filter. You’ll see the change in C6.


Method 4 – Using VBA to Create a Drop Down Filter and Extract Data Based on a Selection in Excel

STEPS:

  • The dataset is in the vba1 sheet.

VBA to Create a Drop Down Filter to Extract Data Based on Selection in Excel

  • The drop-down filter is in the  vba2 sheet. To filter data in the vba1 sheet according to the drop-down selection in the vba2 sheet.

VBA to Create a Drop Down Filter to Extract Data Based on Selection in Excel

  • Right-click the vba2 sheet.
  • Select View Code.

VBA to Create a Drop Down Filter to Extract Data Based on Selection in Excel

  • In the Module window, enter the code below:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Not Intersect(Range("A2"), Target) Is Nothing Then
        Application.EnableEvents = False
        If Range("A2").Value = "" Then
            Worksheets("vba1").ShowAllData
        Else
            Worksheets("vba1").Range("A2").AutoFilter 1, Range("A2").Value
        End If
        Application.EnableEvents = True
    End If
End Sub

VBA to Create a Drop Down Filter to Extract Data Based on Selection in Excel

  • Press F5.
  • In the Macros dialog box, enter VBA in Macro Name:.
  • Click Create.

VBA to Create a Drop Down Filter to Extract Data Based on Selection in Excel

  • Press F5 and select Run.

  • Close the window. From the Drop-Down Filter, select TV.

You’ll see the filtered data in the vba1 sheet.

Select AC from the drop-down filter in the vba2 sheet to see the extracted data.


Download Practice Workbook

Download the following workbook.


Related Articles


<< Go Back to Create Drop-Down List in ExcelExcel Drop-Down List | Data Validation in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Aung Shine
Aung Shine

Aung Shine completed his bachelor’s in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. It has been almost 2 years since he joined SOFTEKO and actively working on the ExcelDemy project. Currently he works as a Team Leader where he guides his team members to create technical content. He has published 150+ articles and reviewed 50+ articles. He has also solved various user problems before. He has interests in Data Analysis, Power Query, Advanced Excel,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo