如果单元格等于文本,则删除该行直到范围结束
If Cell equals Text then delete that row until end of range
需要帮助,因为我无法在网上找到任何东西来实现删除从该范围内包含值“X”的任何单元格开始的范围内的所有行。
Dim srchRng As Range
Set srchRng = Range("A10:A308")
Dim c As Range
For Each c In srchRng
If c.Value = "X" Then
' Delete rows starting with row containing X until A308
Exit For
End If
Next
End Sub
Dim srchRng As Range
Set srchRng = Range("A10:A308")
Dim c As Range
For Each c In srchRng
If c.Value = "X" Then
range(c, range("A308")).entirerow.delete
Exit For
End If
Next
End Sub
您也可以不循环执行此操作。
Dim srchRng As Range
Dim Res As Variant
Set srchRng = Range("A10:A308")
Res = Application.Match("X", srchRng, 0)
If Not IsError(Res) Then
With srchRng
.Offset(Res - 1).Resize(.Rows.Count - Res + 1).EntireRow.Delete
End With
End If
需要帮助,因为我无法在网上找到任何东西来实现删除从该范围内包含值“X”的任何单元格开始的范围内的所有行。
Dim srchRng As Range
Set srchRng = Range("A10:A308")
Dim c As Range
For Each c In srchRng
If c.Value = "X" Then
' Delete rows starting with row containing X until A308
Exit For
End If
Next
End Sub
Dim srchRng As Range
Set srchRng = Range("A10:A308")
Dim c As Range
For Each c In srchRng
If c.Value = "X" Then
range(c, range("A308")).entirerow.delete
Exit For
End If
Next
End Sub
您也可以不循环执行此操作。
Dim srchRng As Range
Dim Res As Variant
Set srchRng = Range("A10:A308")
Res = Application.Match("X", srchRng, 0)
If Not IsError(Res) Then
With srchRng
.Offset(Res - 1).Resize(.Rows.Count - Res + 1).EntireRow.Delete
End With
End If