Filter Data Sets on Multiple Columns with Multiple Criteria at Once in Excel - AutoFilter
This is a really useful filtering macro in Excel and it is pretty straightforward in terms of its use. Currently there are two lines in the macro and they are almost identical except for the field which is being filtered. To filter more fields or columns simply copy and paste this line in the macro (Range("A1").AutoFilter Field:=2, Criteria1:="Enter Criteria Here" ) and change the field number and the criteria. That is all you have to do to filter more than two columns at once. Just make sure that you replace "Enter Criteria Here" with your own criteria and that you change the field number to the desired field number with every new autofilter.
How Filter Macros WorkAll of the elements below often appear within autofilter macros.
This should be the start of the data set, table, or list which you would like to filter. This can also be the entire range reference to the table. For example, if the table was from cell A1:D450, you could put that as the range or you could put A1 as the range. You can do this because the autofilter feature in Excel will automatically try to determine the total range which you would like to filter.
This is the number of the column within the data table that you would like to filter. The first field (1) is the very first column in the data set that will be filtered. This means that if your data starts in column B and your range is Range("B1") and you want to filter based on column D, you would put 3 in for the field.
This is the criteria by which you would like to filter. Some of the macros have symbols within the quotation marks after this argument and those symbols (such as <,>,*,?, etc.) should be left where they are in order to retain the functionality of the macro.
You will not have to change this. This is simply the way to perform different types of filter features in Excel.
Where to install the macro: Module
Excel Macro to Filter Data Sets on Multiple Columns with Multiple Criteria at Once in Excel - AutoFilter
Range("A1").AutoFilter Field:=1, Criteria1:="Enter Criteria Here"
Range("A1").AutoFilter Field:=2, Criteria1:="Enter Criteria Here"
How to Install the Macro
- Select and copy the text from within the grey box above.
- Open the Microsoft Excel file in which you would like the Macro to function.
- Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.
Or For other ways to get there, Click Here.
- On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.
- If the Macro goes in a Module, Click Here, otherwise continue to Step 8.
- If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.
- If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
- Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.
- You are now ready to run the macro.