Range("H6:H20").Select ’宏差错,小于5的错误单元格涂色
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="5"
Selection.FormatConditions(1).Interior.ColorIndex = 8
... ...
Dim isAllOK As Boolean
isAllOK = True
For i = 6 To 20
If Range("H" & i).FormatConditions(1).Interior.ColorIndex =8 Then
isAllOK = False
Msgbox "H" & i & "错误"
End If
Next i
问题是:错误行能准确涂色,但是If Range("H" & i).FormatConditions(1).Interior.ColorIndex =8 ,这句判断的结果是,无论有没有错误,总是每行的isAllOK = False。手动涂色这个程序也没问题,对于宏涂的颜色怎样控制呢?似乎用过宏以后,每行都是错的,无法再通过颜色判断?