G
Gilbert
I'm trying to apply conditioning formatting to different ranges, but when I
run the macro, it only applies it to the last range.
I hope it makes sense
Sub subtotal()
'
' subtotal Conditional
'
'
Range("G9").Select
Cells.FormatConditions.Delete
Range("G9:G200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=F9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("L9").Select
Cells.FormatConditions.Delete
Range("L9:L200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=K9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("Q9").Select
Cells.FormatConditions.Delete
Range("q9:q200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=P9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("V9").Select
Cells.FormatConditions.Delete
Range("v9:v200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=U9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("AA9").Select
Cells.FormatConditions.Delete
Range("AA9:AA200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=Z9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("AF9").Select
Cells.FormatConditions.Delete
Range("AF9:AF200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AE9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Range("B2").Select
End Sub
run the macro, it only applies it to the last range.
I hope it makes sense
Sub subtotal()
'
' subtotal Conditional
'
'
Range("G9").Select
Cells.FormatConditions.Delete
Range("G9:G200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=F9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("L9").Select
Cells.FormatConditions.Delete
Range("L9:L200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=K9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("Q9").Select
Cells.FormatConditions.Delete
Range("q9:q200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=P9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("V9").Select
Cells.FormatConditions.Delete
Range("v9:v200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=U9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("AA9").Select
Cells.FormatConditions.Delete
Range("AA9:AA200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=Z9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("AF9").Select
Cells.FormatConditions.Delete
Range("AF9:AF200").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AE9=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Range("B2").Select
End Sub