ChartObjects Method

Applies To

Chart Object, DialogSheet Object, Worksheet Object.

Description

Accessor. Returns an object that represents a single embedded chart (a ChartObject object, Syntax 1) or a collection of all the embedded charts (a ChartObjects object, Syntax 2) on the sheet.

Syntax 1

object.ChartObjects(index)

Syntax 2

object.ChartObjects

object

Required. The object to which this method applies. If you specify a Chart object, it must be a chart sheet (it cannot be an embedded chart).

index

Required for Syntax 1. The name or number of the chart (can be an array to specify more than one).

Remarks

This method is not equivalent to the Charts method. This method returns embedded charts; the Charts method returns chart sheets. Use the Chart property to return the chart sheet for an embedded chart object.

See Also

Charts Method.

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