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 に答える