IconCriterion.Icon property (Excel)

Returns or specifies the icon for a criterion in an icon set conditional formatting rule. Read/write.

Syntax

expression.Icon

expression A variable that represents an IconCriterion object.

Remarks

After you set the Icon property for the icon criterion in an icon set conditional formatting rule, the IconSet property of the IconSetCondition object is changed to xlCustomSet.

Example

The following code example creates an icon set conditional formatting rule that displays four icons split across the specified percentages. The icon set is initially set to use the 4 Arrows (Colored) icon set, but the Icon property is used to override which icons are used for the first and third criteria.

After running the code, the icon for the first criterion is the Red Cross icon, the icon for the second criterion is the second arrow from the 4 Arrows (Colored) icon set, the icon for the third criterion is the Yellow Traffic Light icon, and the icon for the fourth criterion is the fourth arrow from 4 Arrows (Colored) icon set.

Range("A1:A10").Select 
Selection.FormatConditions.AddIconSetCondition 
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority 
 
With Selection.FormatConditions(1) 
 .ReverseOrder = False 
 .ShowIconOnly = False 
 .IconSet = ActiveWorkbook.IconSets(xl4Arrows) 
End With 
 
With Selection.FormatConditions(1).IconCriteria(1) 
 .Icon = xlIconRedCross 
End With 
 
With Selection.FormatConditions(1).IconCriteria(2) 
 .Type = xlConditionValuePercent 
 .Value = 25 
 .Operator = 7 
End With 
 
With Selection.FormatConditions(1).IconCriteria(3) 
 .Type = xlConditionValuePercent 
 .Value = 50 
 .Operator = 7 
 .Icon = xlIconYellowTrafficLight 
End With 
 
With Selection.FormatConditions(1).IconCriteria(4) 
 .Type = xlConditionValuePercent 
 .Value = 75 
 .Operator = 7 
End With

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.