1

我有一个 excel 表......我想根据以下条件为单元格着色:

  1. 如果单元格 E 不为空,则单元格 A、单元格 B、单元格 C、单元格 D、单元格 F、单元格 G、单元格 H 和单元格 I 不能为空。如果发现任何一个单元格为空,则将相应的单元格涂成红色!!

  2. 如果单元格 A、单元格 B、单元格 C、单元格 D、单元格 F、单元格 G、单元格 H 和单元格 I 共同包含一个值并且单元格 E 为空,则以红色突出显示单元格 E。

注意:想要在模块部分实现这个......所以建议相应的解决方案!

4

1 回答 1

1

像这样的东西会起作用吗?

Dim Row
Row = 3

If Not IsEmpty(Cells(Row, 5)) Then
    ' if Cell E is not empty, then highlight empty cols A-I
    For chkcol = 1 To 9
        If chkcol <> 5 Then ' ignore column E
            If IsEmpty(Cells(Row, chkcol)) Then
                Cells(Row, chkcol).Interior.ColorIndex = 3
            End If
        End If
    Next
Else
    blnvalid = True
    ' check for cell E being empty and all others not
    For chkcol = 1 To 9
        If chkcol <> 5 Then
            If IsEmpty(Cells(Row, chkcol)) Then
                blnvalid = False
                Exit For
            End If
        End If
    Next
    If blnvalid Then
        Cells(Row, 5).Interior.ColorIndex = 3
    End If
End If
于 2012-11-26T17:44:20.043 回答