Add Method (SeriesCollection Collection)

Applies To

SeriesCollection collection object.

Description

Adds one or more new series to the SeriesCollection collection.

Syntax

expression.Add(Source, Rowcol, SeriesLabels, CategoryLabels, Replace)

expression Required. An expression that returns a SeriesCollection object.

Source Required Variant. The new data, either as a Range object or an array of data points.

Rowcol Optional Variant. Specifies whether the new values are in the rows or columns of the specified range. Can be one of the following XlRowCol constants: xlRows or xlColumns. The default value is xlColumns.

SeriesLabels Optional Variant. 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 location of the series name from the contents of the first row or column.

CategoryLabels Optional Variant. 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 location of the category label from the contents of the first row or column.

Replace Optional Variant. If CategoryLabels is True and Replace is True, the specified categories replace the categories that currently exist for the series. If Replace is False, the existing categories will not be replaced. The default value is False.

See Also

Extend method, NewSeries 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 example creates a new series on the embedded chart on Sheet1.

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