How to add a series collection to a chart in Excel VBA

Viewed 93

The code below copies a chart, selects another worksheet and if there is not already a chart, the copied chart is pasted (m=1). If there is already a chart, I want the series collection to be added to this chart.
For some reason, and I really cannot reproduce it, sometimes not the series collection is added to the existing chart but a complete chart. So, it is not a chart with two series collections but a chart in a chart. How can I fix this?


If m = 1 Then
    ActiveSheet.ChartObjects(1).Copy
    wsSummary.Select
    Cells(2, 7).Select
    ActiveSheet.Paste
    Sheets("summary").Columns(6).ColumnWidth = 2.14
    wsSolution.Select
Else:
    ActiveSheet.ChartObjects(1).Copy
    Worksheets("summary").Select
    ActiveChart.Paste
    ActiveSheet.ChartObjects(1).Activate
    wsSolution.Select
    '...
End If

Many thanks!

0 Answers
Related