Class ColorScaleCriteria (Excel VBA)

A collection of ColorScaleCriterion objects that represents all of the criteria for a color scale conditional format. Each criterion specifies the minimum, midpoint, or maximum threshold for the color scale. To use a ColorScaleCriteria class variable it first needs to be instantiated, for example


Dim csc as ColorScaleCriteria
Set csc = ActiveCell.FormatConditions(1).ColorScaleCriteria

For Each

Here is an example of processing the ColorScaleCriteria items in a collection.


Dim cscColorScaleCriteria As ColorScaleCriterion
For Each cscColorScaleCriteria In ActiveCell.FormatConditions(1).ColorScaleCriteria
	
Next cscColorScaleCriteria

Count

Returns a Long value that specifies the number of criteria for a color scale conditional formatting rule.

The number of criteria is equivalent to the number of threshold values assigned for a color scale. This will be either two or three, depending on whether you use a two-color scale or a three-color scale for the conditional formatting rule.


Dim lngCount As Long
lngCount = ActiveCell.FormatConditions(1).ColorScaleCriteria.Count

Item

Returns a single ColorScaleCriterion object from the ColorScaleCriteria collection.

The value of the Index parameter cannot be greater than the number of criteria set for a color scale conditional format. The criteria are equivalent to the threshold values assigned for the color scale. To find the number of threshold values, use the Count property.

Item (Index)

Index: The index number of the ColorScaleCriterion object.


Dim cscItem As ColorScaleCriterion
Set cscItem = ActiveCell.FormatConditions(1).ColorScaleCriteria(Index:=1)