删除“ TH值”之前的所有行(第1行除外)

问题描述 投票:0回答:1

我想做的是删除绿色突出显示“ TH值”之前的所有行。

“

我尝试了几乎所有方法,但收效甚微。我绝对需要帮助。

Sub Search_Range_For_Text()
Dim cell As Range

    For Each cell In Range("b1:b100")
        If InStr(1, cell.Value, "After Upd") > 0 Then
            cell.Offset(0, 0).Value = "TH Value"
            cell.Interior.ColorIndex = 4

            MsgBox "Scroll down to find TH Value which is highlighted green.  Check field notes to verify if there was a check shot"
        Exit For
      End If

Next cell

End Sub

此图像代表我正在尝试实现的结果:

“

excel vba string delete-row
1个回答
0
投票
Sub DeleteBelow()
    Dim cell As Range
    '// Set find format: green color
    With Application.FindFormat.Interior
        .Color = RGB(0, 255, 0) '//green color
    End With
    '// Set 'SearchFormat = True' to use FindFormat
    Set cell = Range("B:B").Find(What:="*", SearchFormat:=True)
    If Not cell Is Nothing Then
        '// Delete all rows beneath found cell (down to the last sheet row)
        Rows(cell.Row + 1 & ":" & Rows.Count).Delete
    Else
        MsgBox "No cell was found.", vbExclamation
    End If
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.