欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

VBA 删除有颜色的行

程序员文章站 2024-01-27 16:09:07
...
Dim lecNum As Integer
    Dim lecturelastRow As Integer
    lecturelastRow = ActiveWorkbook.Sheets("sheeet1").UsedRange.Rows.Count
    For lecNum = 0 To lecturelastRow

        '将第二列是红色的行删除
        If Cells(lecNum, 2).Interior.ColorIndex = 3 Then
           Rows(lecNum).Delete shift:=xlUp
           Exit For
        End If
    Next
相关标签: vba