Class SparklineGroups (Excel VBA)

The class SparklineGroups represents a collection of sparkline groups. To use a SparklineGroups class variable it first needs to be instantiated, for example


Dim sgs as SparklineGroups
Set sgs = ActiveCell.SparklineGroups

For Each

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


Dim sprlng As SparklineGroup
For Each sprlng In ActiveCell.SparklineGroups
	
Next sprlng

Add

Creates a new sparkline group and returns a SparklineGroup object.

Add (Type, SourceData)


Range("$A$1:$A$4").SparklineGroups.Add Type:=xlSparkColumn, SourceData:= _ 
 "Sheet2!B1:E4"

Arguments

The following arguments are required:

Type (XlSparkType) - The type of sparkline.

Possible return values are xlSparkColumn - A column chart sparkline, xlSparkColumnStacked100 - A win/loss chart sparkline, xlSparkLine - A line chart sparkline.

SourceData (String) - Represents the range to use to create the sparkline.

Clear

Clears the selected sparklines.


ActiveCell.SparklineGroups.Clear

ClearGroups

Clears the selected sparkline groups.


ActiveCell.SparklineGroups.ClearGroups

Count

Returns the count of sparkline groups in the associated Range object.


Dim lngCount As Long
lngCount = ActiveCell.SparklineGroups.Count

Group

Groups the selected sparklines.

Group (Location)

Location: The location of the first cell in the group.


Range("A1:A4").SparklineGroups.Group Location:=Range("A1")

Item

Returns a SparklineGroup object from a collection.

Item (Index)

Index: Specifies the position of an element in the collection.


Dim sprlngItem As SparklineGroup
Set sprlngItem = ActiveCell.SparklineGroups(Index:=1)

Ungroup

Ungroups the sparklines in the selected sparkline group.


Range("A1:A4").SparklineGroups.Ungroup