Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to program a macro in Excel that would highlight the entire row green if the following conditions are met:

Emergency Type (Column B) = """"
In Window (Column N) = "On time"
Status (Column O) = "Successful"

The range is dynamic, but for the purpose of this example it is A2:P236.
I would appreciate any help on this. Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
946 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...