仅突出显示单元格时删除完整的行

时间:2018-12-19 15:13:04

标签: excel vba

我选择了一个包含4个单元格的盒子。

如何删除所选单元格的整行?

2 个答案:

答案 0 :(得分:1)

使用默认选择器就足够了。

Selection.EntireRow.Delete

答案 1 :(得分:0)

更改范围并尝试:

Option Explicit

Sub Test()

    Dim i As Long
    Dim rng As Range

    With ThisWorkbook.Worksheets("Sheet1")

        Set rng = .Range("A10:D20")

        For i = rng.Row + rng.Rows.Count - 1 To rng.Row Step -1
           Rows(i).EntireRow.Delete
        Next

    End With

End Sub