问题
Can you please let check what is the error in below vba macro? Trying to autofilter two columns based on criteria. I am not able to filter field 8 and field 9 based on below code.
Worksheets("Demo_Sheet").Activate
With Worksheets("Demo_Sheet").Range("A1")
.AutoFilter field:=8, Criteria1:="<=" & Format(Now() + 5, "m/d/yyyy"), Criteria2:=">=" & Format(Now() - 5, "m/d/yyyy"), Operator:=xlAnd
.AutoFilter field:=9, Criteria1:=">=.95"
End With
Range("A1").CurrentRegion.Copy
回答1:
this gave me an answer
Worksheets("Demo_Sheet").Activate
Selection.AutoFilter
ActiveSheet.Range("A1").AutoFilter field:=8, Criteria1:="<=" & Format(Now() + 5, "m/d/yyyy"), Criteria2:=">=" & Format(Now() - 5, "m/d/yyyy"), Operator:=xlAnd
ActiveSheet.Range("A1").AutoFilter field:=9, Criteria1:=">=.95"
Range("A1").CurrentRegion.Copy
来源:https://stackoverflow.com/questions/58821646/autofilter-for-multiple-columns-in-excel-vba