根据特定单元格的值为excel表单的多个单元格着色

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

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

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

注意:要在模块部分实现这个…所以build议相应的解决scheme!

会这样的工作吗?

Dim Row Row = 3 If Not IsEmpty(Cells(Row, 5)) Then ' if Cell E is not empty, then highlight empty cols AI 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