过滤后,如何select去掉Excel中可见的行?
After filtering, how to select and remove visible rows in Excel?
ActiveSheet.Range("$A:$O64").AutoFilter Field:=7, Criteria1:="promo"
ActiveSheet.Range("$A:$O64").AutoFilter Field:=12, Criteria1:="="
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
我想select过滤后的可见行。我阅读了一些使用 .SpecialCells(xlCellTypeVisible) 的 post 但我不确定如何修改现有代码。
你可以这样做(过滤后):
' Update: don't select the header
Activesheet.Range("$A:$O64").SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete
'Put after this to your filter code
If Application.WorksheetFunction.Subtotal(3, Range("A1:A1464")) > 1 then
Range("$A:$A64").EntireRow.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
else
Msgbox "Criteria not found"
end if
ActiveSheet.Range("$A:$O64").AutoFilter Field:=7, Criteria1:="promo"
ActiveSheet.Range("$A:$O64").AutoFilter Field:=12, Criteria1:="="
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
我想select过滤后的可见行。我阅读了一些使用 .SpecialCells(xlCellTypeVisible) 的 post 但我不确定如何修改现有代码。
你可以这样做(过滤后):
' Update: don't select the header
Activesheet.Range("$A:$O64").SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete
'Put after this to your filter code
If Application.WorksheetFunction.Subtotal(3, Range("A1:A1464")) > 1 then
Range("$A:$A64").EntireRow.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
else
Msgbox "Criteria not found"
end if