This project has moved and is read-only. For the latest updates, please go here.

Howto add an Excel chart series programatically

Dec 2, 2014 at 7:31 PM
Please can you help me? In VBA what I want would be:

ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
ActiveChart.FullSeriesCollection(1).Name = "=""Series1"""
ActiveChart.FullSeriesCollection(1).XValues = "={1,2,3,4,5}"
ActiveChart.FullSeriesCollection(1).Values = "={1,3,5,7,9}"
Dec 3, 2014 at 2:55 PM
Solution appears to be to call SeriesCollection.Add with a dummy range parameter.

Dim sc As SeriesCollection = chartObj.Chart.SeriesCollection
Dim series As Series = sc.Add(sht.Range("A2:A4"))
series.Name = "=""Series1"""
series.XValues = "={1,2,3,4,5}"
series.Values = "={1,3,5,7,9}"