删除具有特定文本和范围的所有行

这是我的代码到目前为止。 问题是它删除了第一行。 我想排除第一行(标题)。 因为我删除的行是重复的标题

[Code] Dim Firstrow As Long Dim Lastrow As Long Dim Lrow As Long Dim CalcMode As Long Dim ViewMode As Long

With Application CalcMode = .Calculation .Calculation = xlCalculationManual .ScreenUpdating = False End With With ActiveSheet.Select ViewMode = ActiveWindow.View ActiveWindow.View = xlNormalView .DisplayPageBreaks = False Firstrow = .UsedRange.Cells(2).Row Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row For Lrow = Lastrow To Firstrow Step -2 With .Cells(Lrow, "D") If Not IsError(.Value) Then If .Value = "Service Tower" Then .EntireRow.Delete End If End With Next Lrow End With ActiveWindow.View = ViewMode With Application .ScreenUpdating = True .Calculation = CalcMode End With [code] 

 .UsedRange.Cells(2) 

是UsedRange的第一行上的第二个单元格。 单元格从左到右,然后从上到下(即“行 – 主”而不是“列 – 主”)计数

你要

 Firstrow = .UsedRange.Rows(2).Row