Using SeriesCollection.Extend for a specific Chart Data Series

F

Frank & Pam Hayes

I have been trying to extend only the second data series in an XY
Scatterchart that has three series in it using the SeriesCollection.Extend
method. The VBA code extends all the data series with the new data, not
just the 2nd series that I want to extend.

My data is laid out in a worksheet called "Sheet1" with the X values in
Column A and the Y values in Column B. Let's assume that Series1 has its
values in rows 1 to 5, Series2 has its values in rows 6 to 10, and Series3
has its values in rows 11 to 15. These values are already charted in a
Chart Sheet called Chart1.

Now I want to use VBA to extend my existing chart. I want to extend Series2
by adding the values in rows 16 to 20. I use the following macro:

Sub TestExtend()

Charts("Chart1").SeriesCollection(2).Select
ActiveChart.SeriesCollection.Extend _
Worksheets("Sheet").Range("A16:B20"), xlColumns, True

End Sub

However, this macro extends all three existing series (1, 2, and 3) with the
new data, not just Series2 as I wanted.

Any ideas?

Please note: I have already determined that the Extend method will only work
with a range and not with an array value so the first three dataseries must
have been entered as ranges, either programmatically or via the Chart ...
Source Data ... Add dialog box.

Thanks,

Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top