到目前为止,这是我的代码。问题是它删除了第一行。我想排除第一行(标题)。因为我删除的行是重复的标题
[代码] Dim Firstrow As Long 昏暗的拉斯特罗长 Dim Lrow As Long Dim CalcMode很长 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]
答案 0 :(得分:1)
.UsedRange.Cells(2)
是UsedRange第一行的第二个单元格。细胞从左到右然后从上到下计数(即"行 - 主要"不是"列专业")
你想要
Firstrow = .UsedRange.Rows(2).Row