Class SparklineGroup (Excel VBA)

The class SparklineGroup represents a group of sparklines.

Set

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

Dim strSourceData As String: strSourceData = 
Dim rng As Range: Set rng = 
Dim sprlng As SparklineGroup
Set sprlng = rng.SparklineGroups.Add(Type:=xlSparkColumn, SourceData:=strSourceData)

SparklineGroup class variables can be set using the Range.SparklineGroups procedure.

For Each

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

Dim rng As Range: Set rng = 
Dim sprlngSparklineGroup As SparklineGroup
For Each sprlngSparklineGroup In rng.SparklineGroups
	
Next sprlngSparklineGroup

SparklineGroups.Add

Creates a new sparkline group and returns a SparklineGroup object.

Syntax : expression.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 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.

SparklineGroups.Clear

Clears the selected sparklines.

SparklineGroups.ClearGroups

Clears the selected sparkline groups.

SparklineGroups.Count

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

SparklineGroups.Group

Groups the selected sparklines.

Syntax : expression.Group (Location)

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

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

SparklineGroups.Item

Returns a SparklineGroup object from a collection.

Syntax : expression.Item (Index)

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

SparklineGroups.Parent

Returns the Range object for the specified object. Read-only.

SparklineGroups.Ungroup

Ungroups the sparklines in the selected sparkline group.

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