excel vba formatconditions range code example
Example: excel vba formatconditions range
Dim MyRange As Range
Set MyRange = ThisWorkbook.Worksheets(1).Range("A1:C10")
With MyRange ' whole row into red when A value <> B value
.Cells(1, 1).FormatConditions.Add Type:=xlExpression, Formula1:="=$A1<>$B1"
.FormatConditions(1).Font.Color = vbRed
.Cells.FormatConditions(1).ModifyAppliesToRange MyRange
End With