carrieebacon
New Member
- Joined
- Jan 15, 2024
- Messages
- 49
- Office Version
- 365
- Platform
- Windows
I am trying to apply the following conditional formatting to a macro. It is creating the formulas and applying them to the correct range, but it is only setting the format for the first formula. Any ideas?
This is my code:
Sub CondishFormatMulti()
Dim MyRange As Range
Set MyRange = Range("$E:$E, $I:$I, $M:$M, $Q:$Q")
MyRange.FormatConditions.Delete
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=0.1", Formula2:="=0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 230, 153)
MyRange.FormatConditions(1).Font.Color = RGB(128, 96, 0)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=-0.1", Formula2:="=-0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 230, 153)
MyRange.FormatConditions(1).Font.Color = RGB(128, 96, 0)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=0.001", Formula2:="=0.1"
MyRange.FormatConditions(1).Interior.Color = RGB(198, 224, 180)
MyRange.FormatConditions(1).Font.Color = RGB(55, 86, 35)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=-0.001", Formula2:="=-0.1"
MyRange.FormatConditions(1).Interior.Color = RGB(198, 224, 180)
MyRange.FormatConditions(1).Font.Color = RGB(55, 86, 35)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="=0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
MyRange.FormatConditions(1).Font.Color = RGB(0, 0, 0)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=-0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
MyRange.FormatConditions(1).Font.Color = RGB(0, 0, 0)
End Sub
This is my code:
Sub CondishFormatMulti()
Dim MyRange As Range
Set MyRange = Range("$E:$E, $I:$I, $M:$M, $Q:$Q")
MyRange.FormatConditions.Delete
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=0.1", Formula2:="=0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 230, 153)
MyRange.FormatConditions(1).Font.Color = RGB(128, 96, 0)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=-0.1", Formula2:="=-0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 230, 153)
MyRange.FormatConditions(1).Font.Color = RGB(128, 96, 0)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=0.001", Formula2:="=0.1"
MyRange.FormatConditions(1).Interior.Color = RGB(198, 224, 180)
MyRange.FormatConditions(1).Font.Color = RGB(55, 86, 35)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=-0.001", Formula2:="=-0.1"
MyRange.FormatConditions(1).Interior.Color = RGB(198, 224, 180)
MyRange.FormatConditions(1).Font.Color = RGB(55, 86, 35)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="=0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
MyRange.FormatConditions(1).Font.Color = RGB(0, 0, 0)
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=-0.5"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
MyRange.FormatConditions(1).Font.Color = RGB(0, 0, 0)
End Sub