繁体   English   中英

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

[英]Delete all rows with specific text and range

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

[代码] Dim Firstrow与Long Dim Lastrow与Long Dim Lrow与Long Dim CalcMode与Long Dim ViewMode与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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM