Chart.ChartObjects method (Excel)
Returns an object that represents either a single embedded chart (a ChartObject object) or a collection of all the embedded charts (a ChartObjects object) on the sheet.
Syntax
expression.ChartObjects (Index)
expression A variable that represents a Chart object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Index | Optional | Variant | The name or number of the chart. This argument can be an array to specify more than one chart. |
Return value
Object
Remarks
This method isn't equivalent to the Charts property of the Workbook object. This method returns embedded charts; the Charts property returns chart sheets.
Use the Chart property of the ChartObject object to return the Chart object for an embedded chart.
Example
This example adds a title to embedded chart one on Sheet1.
With Worksheets("Sheet1").ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = "1995 Rainfall Totals by Month"
End With
This example creates a new series in embedded chart one on Sheet1. The data source for the new series is the range B1:B10 on Sheet1.
Worksheets("Sheet1").ChartObjects(1).Activate
ActiveChart.SeriesCollection.Add _
source:=Worksheets("Sheet1").Range("B1:B10")
This example clears the formatting of embedded chart one on Sheet1.
Worksheets("Sheet1").ChartObjects(1).Chart.ChartArea.ClearFormats
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.