handysmurf
Board Regular
- Joined
- Jan 17, 2015
- Messages
- 114
- Office Version
- 365
- Platform
- Windows
I need to convert these conditional formatting rules to VBA.
Range("C8").Activate
Sub Makro4()
'
' Makro4 Makro
'
Cells.FormatConditions.Delete
Range("C7:D25,F7:F25").Select
Range("C8").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($C8<=90,$D8<=60)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 10092543
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("C8:D25,F8:F25").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($C8=""Meds"",$C8=""P.M.Meds"",$C8=""A.M.Meds"",$C8=""Wake"",$C8=""Sleep"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).StopIfTrue = True
Range("C8:D25,F8:F25").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISBLANK($C8)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).StopIfTrue = True
Range("A8:F25").Select
Range("C8").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A8<>$A9"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Sub Makro4_1()
Cells.FormatConditions.Delete
With Range("C7:D25001,F7:F25001")
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($C8<=90,$D8<=60)"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 10092543
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
With Range("C8:D25001,F8:F25001")
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR($C8=""Meds"",$C8=""P.M.Meds"",$C8=""A.M.Meds"",$C8=""Wake"",$C8=""Sleep"")"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).StopIfTrue = True
End With
With Range("C8:D25001,F8:F25001")
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISBLANK($C8)"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).StopIfTrue = True
End With
With Range("A8:F25001")
.FormatConditions.Add Type:=xlExpression, Formula1:="=$A8<>$A9"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
.FormatConditions(1).StopIfTrue = False
End With
End Sub