我在电子表格中有两个过滤器,我试图检查其中一个是否处于活动状态(H列)。如果已过滤,我只想取消对该列的过滤,如果不是,我想应用过滤器。
这是我当前的代码:
Sub UnFilter()
Dim ws As Excel.Worksheet
Set ws = Worksheets("Ranked Results")
With ws
If Not Intersect(.AutoFilter.Range, .Range("H1")) Is Nothing Then
.Range("$A$2:$K$22003").AutoFilter Field:=8
Else
Dim Company As String
Company = .Range("L2")
.Range("$A$2:$K$22003").AutoFilter Field:=8, Criteria1:=">" & Company, _
Operator:=xlAnd
End If
End With
End Sub