我想在vba中使用变量作为autofilter的列,我想我没有把sintax正确,因为它不起作用:
With ActiveSheet
.AutoFilterMode = False
With .Range("A1:" & LastCol + 1 & "1")
.AutoFilter
.AutoFilter field:=5, Criteria1:="Approved"
.AutoFilter field:=6, Criteria1:="Open"
.AutoFilter field:=LastCol + 1, Criteria1:="1"
End With
End With
答案 0 :(得分:1)
如果没有空白列,则可以改为使用CurrentRegion
(类似于A1
中的Ctrl + A)
ActiveSheet.AutoFilterMode = False
With Cells.CurrentRegion
.AutoFilter 5, "Approved"
.AutoFilter 6, "Open"
.AutoFilter .Columns.Count, "1"
End With