I am trying to apply conditional formats to multiple ranges and can't get the following code to work. Can you use conditional formatting to multiple ranges at one time, and can you store multiple ranges in one variable?
Sub StabYieldCondFormat()
Dim lRow As Integer
Dim x As Variant
Sheets("New PVT").Select
Cells.FormatConditions.Delete
lRow = Range("B" & Rows.Count).End(xlUp).Row
x = Range("Y12:Y" & lRow, "AC12:AC" & lRow)
x.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR(Y12<0.06,Y12>0.1)"
x.FormatConditions(x.FormatConditions.Count).SetFirstPriority
With x.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
x.FormatConditions(1).StopIfTrue = True
x.FormatConditions(1).ScopeType = xlSelectionScope
End Sub
Bookmarks