Hi All,
I need a VBA MS Excel code to duplicate a series in the chart, which has just one series. Effectively, as a result the chart should have two identical serieses.
Thank you for your help!
PS. I tried this code, but it ends up with run-time error...
ActiveChart.ChartArea.Select ' the chart has one series
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Values = ActiveChart.SeriesCollection(1).Values
the error might be because the chart is not selected when you run this code, and there's no ActiveChart. So you can select the chart before running or write a line to reference the desired chart, something like
- Workbooks("theBooksName").worksheets("theSheetsName").chartobjects("theChartsName").activate
of course you can skip the Workbooks part, and replace the worksheets part with ActiveWorksheet, but once again you'll have to be sure to have the right book and sheet selected.
The name of the chart is put by Excel, it should be something like "Chart01" or "Chart02" or something like that. To know it, use the macro recorder. Select anything but the chart, and then select the chart and stop recording. When you see the recorded code, you'll see the chart's name in a line quite similar to the one i've just write above.
HTH