Class Icon (Excel VBA)

The class Icon represents a single icon in an icon set used in a conditional formatting rule.

Item

To use a Icon class variable it first needs to be instantiated, for example

Dim icn as Icon
Set icn = ActiveWorkbook.IconSets(1)(Index:=1)

Icon class variables can be set using the IconSet.Item procedure.

For Each

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

Dim icnParent As Icon
For Each icnParent In ActiveWorkbook.IconSets.Parent
	
Next icnParent

Index

Returns a Long value specifying the index number of the Icon object within the IconSet object.

Dim lngIndex As Long
lngIndex = ActiveWorkbook.IconSets(1)(1).Index

IconSet.Count

Returns a Long value that specifies the number of icons in the icon set.

Dim lngCount As Long
lngCount = ActiveWorkbook.IconSets(1).Count

IconSet.ID

Returns one of the constants of the XlIconSet enumeration, which specifies the name of the icon set used in an icon set conditional formatting rule.

xl3Arrows - 3 Arrows, xl3ArrowsGray - 3 Arrows Gray, xl3Flags - 3 Flags, xl3Signs - 3 Signs, xl3Stars, xl3Symbols - 3 Symbols, xl3Symbols2, xl3TrafficLights1 - 3 Traffic Lights 1, xl3TrafficLights2 - 3 Traffic Lights 2, xl3Triangles, xl4Arrows - 4 Arrows, xl4ArrowsGray - 4 Arrows Gray, xl4CRV - 4 CRV, xl4RedToBlack - 4 Red To Black, xl4TrafficLights - 4 Traffic Lights, xl5Arrows - 5 Arrows, xl5ArrowsGray - 5 Arrows Gray, xl5Boxes, xl5CRV - 5 CRV, xl5Quarters - 5 Quarters, xlCustomSet.
Dim xisID As XlIconSet
xisID = ActiveWorkbook.IconSets(1).ID

IconSet.Item

Returns an Icon object that represents a single icon from an icon set.

The value of the Index parameter cannot be greater than the number of icons in an icon set. To find the total number of icons in an icon set, use the Count property.

Item (Index)

Index: The index number of the Icon object.

Dim icnItem As Icon
Set icnItem = ActiveWorkbook.IconSets(1)(Index:=1)