logandiana
Board Regular
- Joined
- Feb 21, 2017
- Messages
- 107
As you know when using the recorder it often adds a bunch of stuff you don't need.
I am pretty good about cleaning up, but don't use VBA for conditional formatting that often and am not used to seeing a lot of this.
For each of these ranges, I am deleting the current formatting for the range, and then adding the formatting back using the new range.
I see some negativebar stuff it there but I'll never have a negative value here so I would think I could remove that stuff altogether, but not certain.
I am pretty good about cleaning up, but don't use VBA for conditional formatting that often and am not used to seeing a lot of this.
For each of these ranges, I am deleting the current formatting for the range, and then adding the formatting back using the new range.
I see some negativebar stuff it there but I'll never have a negative value here so I would think I could remove that stuff altogether, but not certain.
VBA Code:
With ws
.Range("C14:C" & LR - 1).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.AddDatabar
Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1)
.MinPoint.Modify newtype:=xlConditionValueAutomaticMin
.MaxPoint.Modify newtype:=xlConditionValueAutomaticMax
End With
With Selection.FormatConditions(1).BarColor
.Color = 13012579
End With
.Range("D14:D" & LR - 1).Select
Selection.FormatConditions(1).BarFillType = xlDataBarFillGradient
Selection.FormatConditions(1).Direction = xlContext
Selection.FormatConditions(1).NegativeBarFormat.ColorType = xlDataBarColor
Selection.FormatConditions(1).BarBorder.Type = xlDataBarBorderSolid
Selection.FormatConditions(1).NegativeBarFormat.BorderColorType = xlDataBarColor
With Selection.FormatConditions(1).BarBorder.Color
.Color = 13012579
End With
Selection.FormatConditions(1).AxisPosition = xlDataBarAxisAutomatic
Selection.FormatConditions.Delete
Selection.FormatConditions.AddColorScale ColorScaleType:=3
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).ColorScaleCriteria(1).Type = xlConditionValueNumber
Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 1
With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
.Color = 7039480
End With
Selection.FormatConditions(1).ColorScaleCriteria(2).Type = xlConditionValueNumber
Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 2
With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
.Color = 8711167
End With
Selection.FormatConditions(1).ColorScaleCriteria(3).Type = xlConditionValueNumber
Selection.FormatConditions(1).ColorScaleCriteria(3).Value = 3
With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
.Color = 8109667
End With
End with