Name

chart.Add([Before], [After], [Count])

Synopsis

Creates one or more chart sheets and returns a reference to the first Chart object created.

Argument

Settings

Before

The sheet in the workbook before which the new chart sheet is placed.

After

The sheet in the workbook after which the new chart sheet is placed.

Count

The number of chart sheets to add. Default is 1.

You can’t specify both the Before and After arguments; you must choose one. The following code creates three new chart sheets at the beginning of a workbook and names the first sheet New Chart:

Sub AddCharts(  )
    Dim chrt As Chart
    Set chrt = Charts.Add(Sheets(1), , 3)
    chrt.Name = "New Chart"
End Sub

The other two charts receive default names (Chart n).

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.