我需要删除所有值为 5.0.0 的行,并创建/使用自动过滤器来过滤该值。
第四行是我删除所有包含该值的行的地方。当我这样做时,列标题也会被删除。
使用 ws.
可能会更容易,但是工作表的名称会随着时间而改变,所以我想避免使用它。
Columns ("L").Select
Selection.Autofilter
ActiveSheet.Range("$F$1:$H$13889").AutoFilter Field:=1, Criteria1:="5.0.0"
ActiveCell.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
最佳答案
我认为你的 Range("$F$1...) 把你搞砸了。试试这个:
Option Explicit
Sub DeleteFilteredRows()
Dim rngFltr As Range
Dim lLastRow As Long
Application.ScreenUpdating = False 'Keep screen from flickering
lLastRow = Cells(Rows.Count, "L").End(xlUp).Row
Set rngFltr = Range(Cells(1, "L"), Cells(lLastRow, "L"))
With rngFltr
.AutoFilter Field:=1, Criteria1:="5.0.0"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With 'rngFltr
ActiveSheet.AutoFilterMode = False 'Clear Filter
Application.ScreenUpdating = True 'Update Screen
End Sub 'DeleteFilteredRows
高温高压
关于excel - 删除所有具有自动填充值的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63333160/