ActiveSheet.Range("$A$1:$O$1464").AutoFilter Field:=7, Criteria1:="promo"
ActiveSheet.Range("$A$1:$O$1464").AutoFilter Field:=12, Criteria1:="="
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
我想在过滤后选择可见的行。我阅读了一些使用.SpecialCells(xlCellTypeVisible)的帖子,但不确定如何修改现有代码。
答案 0 :(得分:0)
您可以通过这种方式(过滤后)进行操作:
' Update: don't select the header
Activesheet.Range("$A$2:$O$1464").SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete
答案 1 :(得分:-1)
'Put after this to your filter code
If Application.WorksheetFunction.Subtotal(3, Range("A1:A1464")) > 1 then
Range("$A$2:$A$1464").EntireRow.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
else
Msgbox "Criteria not found"
end if