ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding rows in a chart (https://www.excelbanter.com/excel-programming/298112-adding-rows-chart.html)

art

Adding rows in a chart
 
Hi
I'm trying to add rows in a chart. This is a line chart, getting the values from a data sheet. It is to create a line from one row of data, then go down a row and add a second row of data. It does this, but replaces the existing line with the new data. How can I get it to not replace the existing data, but add a new line to it? Here is what I have:

(variables - RW is the row, I is the column)

Charts.Add
ActiveChart.ChartType = xlLine
For J = 1 To 15 Step 1
ActiveChart.SetSourceData Source:=Sheets("Data").Cells(RW, I).Offset(0, -9).Resize(1, 10), PlotBy:=xlRows
ActiveChart.SeriesCollection(1).Name = Worksheets("Data").Cells(RW, 1).Value
RW = RW + 1
Next J


Thanks. Art

Jon Peltier[_7_]

Adding rows in a chart
 
Art -

Add a new series:

For J = 1 To 15 Step 1
ActiveChart.SeriesCollection.Add Source:=Sheets("Data").Cells(RW,
I).Offset(0, -9).Resize(1, 10), RowCol:=xlRows
ActiveChart.SeriesCollection(J).Name = Worksheets("Data").Cells(RW, 1).Value
RW = RW + 1
Next J

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Art wrote:

Hi
I'm trying to add rows in a chart. This is a line chart, getting the values from a data sheet. It is to create a line from one row of data, then go down a row and add a second row of data. It does this, but replaces the existing line with the new data. How can I get it to not replace the existing data, but add a new line to it? Here is what I have:

(variables - RW is the row, I is the column)

Charts.Add
ActiveChart.ChartType = xlLine
For J = 1 To 15 Step 1
ActiveChart.SetSourceData Source:=Sheets("Data").Cells(RW, I).Offset(0, -9).Resize(1, 10), PlotBy:=xlRows
ActiveChart.SeriesCollection(1).Name = Worksheets("Data").Cells(RW, 1).Value
RW = RW + 1
Next J


Thanks. Art




All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com