簡體   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