Color Scale Object Example

This example adds a three-color scale formatting rule to a specified range:

Sub CreateColorScale()

Dim oColorScale As ColorScale

'Add a three-color scale

Set oColorScale = Range("F6:F16").FormatConditions.AddColorScale(ColorScaleType:=3) 'Set the minimum threshold to the lowest value in the range 'Set the color for the minimum threshold oColorScale.ColorScaleCriteria(1).Type = xlConditionValueLowestValue oColorScale.ColorScaleCriteria(1).FormatColor.Color = 7039480 'Set the midpoint threshold to the value in a specific cell (cell F10 in this case) 'Set the for the midpoint threshold oColorScale.ColorScaleCriteria(2).Type = xlConditionValueNumber oColorScale.ColorScaleCriteria(2).Value = "=$F$10" oColorScale.ColorScaleCriteria(2).FormatColor.Color = 49407 'Set the maximum threshold to the lowest value in the range 'Set the color for the maximum threshold oColorScale.ColorScaleCriteria(3).Type = xlConditionValueHighestValue oColorScale.ColorScaleCriteria(3).FormatColor.Color = 8109667

0 0

Post a comment