Stop searching. Start learning and developing your excel skills.
Macro
VBA
Formula
Function
Shortcut
Tricks

» » VBA To Filter Multiple Criteria

VBA To Filter Multiple Criteria

June 03, 2017 |
This is also related to below queries:
  1. vba autofilter multiple fields
  2. excel vba filter multiple criteria array
  3. excel vba filter multiple criteria same column
  4. vba filter more than 2 criteria
  5. vba autofilter 3 criteria
  6. vba advanced filter multiple criteria
The Code:
Dim i As Long
i = Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("$A$1:$E$" & i).AutoFilter Field:=1, Criteria1:=Array("APAA", "APAB", "APAC"), Operator:=xlFilterValues

Where:
  1. i  = total rows
  2. ("$A$1:$E$" & i) is a range from cell A1 until Ei where i = number of rows/ total rows. Change according to your requirement
  3. AutoFilter Field:=1 is column A. Change AutoFilter Field:=2 for column B or AutoFilter Field:=3 for column C and so on
  4. Criteria1:=Array("APAA", "APAB", "APAC"). Change "APAA","APAB","APAC" to your requirements. You can just simply add more criteria to filter

No comments:

Post a Comment