在下面的代码中,如果代码在列G的单元格中找到“0”,那么该行中的几个单元格将被着色,我希望这些单元格仅在在同一行的G列和H列中发现值“0”,这怎么办?为两个单元格的值选择条件并为行着色
With Worksheets("Sheet3")
For Each cell In Range("G2:G" & LastRow)
If cell.Value = "0" Then
cell.Range("A1:F1").Offset(0, -5).Interior.ColorIndex = 20
ElseIf cell.Value = "1" Then
cell.Range("A1:F1").Offset(0, -5).Interior.ColorIndex = 43
Else
cell.EntireRow.Interior.ColorIndex = xlNone
End If
Next
End With
条件格式:'= AND($ G1 = 0 ,$ H1 = 0)' –