如果同一行中的两个特定单元格匹配同一行中的另一个单元格

时间:2014-04-29 18:27:32

标签: excel excel-vba vba

基本上我正按照标题中的说法进行操作。

如果说两个单元格在同一行中完成

Before

然后,删除并突出显示同一行中的另一个单元格 After

2 个答案:

答案 0 :(得分:1)

使用此条件格式公式将条件格式应用于A列:

=C1&D1="donedone"

然后使用删除线和填充颜色黄色

进行格式化

答案 1 :(得分:1)

您想使用条件格式,公式还是VBA?

Conditional Formatting

enter image description here

VBA:

Sub colorCells()
    For x = 1 To Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
        If Cells(x, 3) = "done" And Cells(x, 4) = "done" Then
            Cells(x, 1).Interior.Color = RGB(255, 255, 0)
            Cells(x, 1).Font.Strikethrough = True
        Else
            Cells(x, 1).Interior.Color = xlNone
            Cells(x, 1).Font.Strikethrough = False
        End If
    Next x
End Sub