Add Method (SeriesCollection Collection)

Applies To

SeriesCollection Collection.

Description

Adds one or more new series to the SeriesCollection collection.

Syntax

object.Add(source, rowcol, seriesLabels, categoryLabels, replace)

object

Required. The SeriesCollection object.

source

Required. Specifies the new data, either as a Range or an array of data points.

rowcol

Optional. Specifies whether the new values are in the rows (xlRows) or columns (xlColumns) of the specified range. The default value is xlColumns.

seriesLabels

Optional. Ignored if source is an array. True if the first row or column contains the name of the data series. False if the first row or column contains the first data point of the series. If this argument is omitted, Microsoft Excel attempts to determine the series name location from the contents of the first row or column.

categoryLabels

Optional. Ignored if source is an array. True if the first row or column contains the name of the category labels. False if the first row or column contains the first data point of the series. If this argument is omitted, Microsoft Excel attempts to determine the category label location from the contents of the first row or column.

replace

Optional. If categoryLabels is True and replace is True, the specified categories replace the categories that currently exist for the series. If this argument is False or omitted, the existing categories will not be replaced.

See Also

Extend Method.

Example

This example creates a new series in Chart1. The data source for the new series is range B1:B10 on Sheet1.


Charts("Chart1").SeriesCollection.Add _
    source:=ActiveWorkbook.Worksheets("Sheet1").Range("B1:B10")

This is the same as the preceding example, except that the chart is an embedded chart on Sheet1.


Worksheets("Sheet1").ChartObjects(1).Activate
ActiveChart.SeriesCollection.Add _
    source:=Worksheets("Sheet1").Range("B1:B10")