Class ChartGroups (Excel VBA)

The class ChartGroups represents one or more series plotted in a chart with the same format. To use a ChartGroups class variable it first needs to be instantiated, for example


Dim cgs as ChartGroups
Set cgs = ActiveChart.ChartGroups()

For Each

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


Dim chrg As ChartGroup
For Each chrg In ActiveChart.ChartGroups()
	
Next chrg

Count

Returns a Long value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = ActiveChart.ChartGroups.Count

Item

Returns a single object from a collection.

Item (Index)

Index: The index number for the object.


Dim chrg As ChartGroup
Set chrg = ActiveChart.ChartGroups(Index:=1)