有谁知道在下面的代码中应用高级过滤器之后,我可以在col E中应用另一个来显示过滤数据的唯一值(没有删除已经过滤的内容?) - 任何帮助都会很多理解
Sub difficultQ()
Dim x
Dim Y
x = "Match"
Y = "Match1"
Range("A1").Value = x
Range("A2").Value = Y
Range("M4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, criteriarange:=Range("A1:A2")
' In here I would like to have code that filtered col E
' on unique values, without getting rid of the advanced filter above
End Sub
答案 0 :(得分:1)
您无法应用两个高级过滤器。您需要修改过滤条件并使用公式,例如:
Sub difficultQ()
Dim x
Dim Y
Dim lastRow As Long
Y = "Match1"
Range("A1").Value = vbNullString
Range("A2").Formula = "=AND(M5=""" & Y & """,COUNTIFS($E$5:$E5,E5,M$5:M5,""" & Y & """)=1)"
lastRow = Cells(Rows.Count, "M").End(xlUp).Row
Range("E4:M" & lastRow).AdvancedFilter Action:=xlFilterInPlace, criteriarange:=Range("A1:A2")
End Sub