Filter data for multiple criteria

How to filter data for more than one criteria in a single column using VBA

METHOD 1. Filter data for multiple criteria using VBA

VBA

Sub Filter_for_multiple_criteria()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'filter for win and draw criteria in column C
ws.Range("B2:C9").AutoFilter Field:=2, Criteria1:=Array("win", "draw"), Operator:=xlFilterValues

End Sub

PREREQUISITES
Worksheet Name: Have a worksheet named Sheet1.
Data Range: In this example the data that is being filtered for multiple criteria is captured in range ("B2:C9"). Therefore, if using the exact same VBA code, the VBA code will apply a filter to this range.
Filter Field: In this example we are filtering against the second column by assigning a value of 2 against 'filed', in the VBA code.
ADJUSTABLE PARAMETERS
Worksheet Selection: Select the worksheet that captures the data that you want to filter by changing the Sheet1 worksheet name. in the VBA code to any existing worksheet in the workbook.
Data Range: Select the range that captures the data that you want to filter for multiple criteria in a single column by changing the range reference ("B2:C9").
Filter Field: Select the filter filed by changing the filed number (2) in the VBA code to any number that is withing the applied filter.
Filter Criteria: Select the filter criteria by changing the criteria values "win" and "draw" in the VBA code. If filtering for non numeric values you need to apply the quotation marks around the criteria.

Explanation about how to filter data for multiple criteria

EXPLANATION

EXPLANATION

This tutorial explains and provides step by step instructions on how to filter data for more than one criteria in a single column using VBA.

VBA Method: This tutorial provides a single method that can be used to filter data for multiple criteria in one column.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to filter data using Excel and VBA methods
How to filter by color using Excel and VBA methods
How to filter between two numbers using Excel and VBA methods
How to sort data in an alphabetical order (A to Z) in a column using Excel and VBA methods