Conditional formatting using 3 conditions in Macro/VBA

Programmatically? Try this:

Sub ApplyConditionalFormatting()

Dim applyto As Range

Set applyto = Range("A2:P236") 'you can make this dynamic

Range("A2").FormatConditions.Add Type:=xlExpression, Formula1:= _
    "=AND($B2="""",$N2=""On Time"",$O2=""Successful"")"
With Range("A2").FormatConditions(1)
    .SetFirstPriority
    With .Interior
        .PatternColorIndex = xlAutomatic
        .Color = 5287936
        .TintAndShade = 0
    End With
    .ModifyAppliesToRange applyto
    .StopIfTrue = False
End With

End Sub

HTH.

Leave a Comment