Microsoft Office Tutorials and References
In Depth Information
Working with Sparkline Charts
Rather, you need to use the Cells property (which returns a range object):
MsgBox Cells.SparklineGroups.Count
The following example lists the address of each Sparkline group on the active worksheet:
Sub ListSparklineGroups()
Dim sg As SparklineGroup
Dim i As Long
For i = 1 To Cells.SparklineGroups.Count
Set sg = Cells.SparklineGroups(i)
MsgBox sg.Location.Address
Next i
End Sub
For some reason, you can’t use the For Each construct to loop through the objects in the
SparklineGroups collection. You need to refer to the objects by their index number.
Following is another example of working with Sparklines in VBA. The SparklineReport
procedure lists information about each Sparkline on the active sheet.
Sub SparklineReport()
Dim sg As SparklineGroup
Dim sl As Sparkline
Dim SGType As String
Dim SLSheet As Worksheet
Dim i As Long, j As Long, r As Long
If Cells.SparklineGroups.Count = 0 Then
MsgBox “No sparklines were found on the active sheet.”
Exit Sub
End If
Set SLSheet = ActiveSheet
‘ Insert new worksheet for the report
‘ Headings
With Range(“A1”)
.Value = “Sparkline Report: “ & SLSheet.Name & “ in “ _
& SLSheet.Parent.Name
Search JabSto ::

Custom Search