- How to make a drop down list in excel for sorting how to#
- How to make a drop down list in excel for sorting code#
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: The number 1 in the script: AutoFilter 1 is the column number that you want to filter based on. 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. Worksheets("Sheet2").Range("A2").AutoFilter 1, Range("A2").Value If Not Intersect(Range("A2"), Target) Is Nothing Then VBA code: Filter data from drop down list selection in two sheets: Private Sub Worksheet_Change(ByVal Target As Range)
How to make a drop down list in excel for sorting code#
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: The following VBA code may do you a favor, please do as this:ġ. 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. 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: And then go on dragging the fill handle down to the cells to display all corresponding filtered records, 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.ħ. 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: E2:E17 is the second helper formula cells, D2 is the first cell in first helper formula column.Ħ. 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: 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.ĥ. 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: 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:Ĥ. 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:ģ. Click a cell where you want to insert the drop down list, then click Data > Data Validation > Data Validation, see screenshot:Ģ. To filter data from drop down list, you can create some helper formula columns, please do with the following steps one by one:ġ.
How to make a drop down list in excel for sorting how to#
This article, I will talk about how to filter data by using drop down list in one or two worksheets.įilter data from drop down list selection in one worksheet with helper formulasįilter data from drop down list selection in two worksheets with VBA code 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. In Excel, most of us may filter data by using the Filter feature. How to filter data from drop down list selection in Excel?