"堆积"高级过滤器Excel

时间:2018-04-26 20:14:09

标签: excel vba filter logic advanced-filter

有没有办法实现一个高级过滤器,其行为类似于下面屏幕截图中显示的以下逻辑? (所选单元格代表所需的逻辑)

enter image description here

1 个答案:

答案 0 :(得分:1)

Option Explicit

Public Sub StackedFilter()

    Dim a As Variant, b As Variant, c As Variant

    a = Array("A", "B", "C")
    b = Array("D", "E", "F")
    c = Array("G", "H", "I")

    With ActiveSheet.UsedRange
        .AutoFilter Field:=1, Criteria1:=a, Operator:=xlFilterValues  'Col A filter
        .AutoFilter Field:=2, Criteria1:=b, Operator:=xlFilterValues  'Col A And B
        .AutoFilter Field:=3, Criteria1:=c, Operator:=xlFilterValues  'Col A And B And C
    End With
End Sub