根据条件格式

时间:2016-11-22 21:54:53

标签: excel vba excel-vba

背景

我正在编写一个Sub来审核每天收到的报告。它用于检查3列中的空格和第4列中的重复项,然后删除所有没有问题的行(即没有重复项,没有空格)。

每行中都有空白:

lRow = Range("G" & Rows.Count).End(xlUp).Row

Set MR = Range("D1:D" & lRow)
For Each cell In MR
If cell.Value = "" Then cell.EntireRow.Interior.ColorIndex = 2
Next

Set MR = Range("E1:E" & lRow)
For Each cell In MR
If cell.Value = "" Then cell.EntireRow.Interior.ColorIndex = 2
Next

Set MR = Range("M1:M" & lRow)
For Each cell In MR
If cell.Value = "" Then cell.EntireRow.Interior.ColorIndex = 2
Next

通过条件格式复制:

   Columns("J:J").Select
    Selection.FormatConditions.AddUniqueValues
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).DupeUnique = xlDuplicate
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False

问题

我用来删除“非问题”行的代码只保留整行有填充的行。据我所知,重复项的条件格式不允许突出显示不仅仅是单元格。

为了解决这个问题,我尝试使用一些代码来查找带有条件格式填充(ColorIndex 38)的单元格,并填充整行,但似乎CF实际上并没有填充单元格{{ 1}}返回“-4142”(MsgBox Selection.Interior.ColorIndex)。

问题

我怎么能:

  • 识别有条件格式的单元格并填满整行?

  • 仅删除不包含已填充的单个单元格的行?

0 个答案:

没有答案
相关问题