如果B列中的单元格为红色填充,则删除行

时间:2015-02-28 13:24:28

标签: excel vba

我正在寻找可以删除行的VBA,如果B列中的单元格包含红色填充颜色。

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

这使用特定的Red (ColorIndex#3)

Sub BetterDeadThanRed()
    Dim N As Long
    N = Cells(Rows.Count, "B").End(xlUp).Row
    For i = N To 1 Step -1
        If Cells(i, "B").Interior.ColorIndex = 3 Then
            Cells(i, "B").EntireRow.Delete
        End If
    Next i
End Sub

注意

我们从下往上运行循环。
这个子不是很快。