How to add new data points to existing series?

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
Hello,

I would like to add new data points, one by one, to an existing data series...

Is there any way to do this in VBA using a construct similar to adding a new series (SeriesCollection.NewSeries), such as SeriesCollection(1).NewPoint?

Thanks for any help!

Kelvin
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Hello,

I would like to add new data points, one by one, to an existing data series...

Is there any way to do this in VBA using a construct similar to adding a new series (SeriesCollection.NewSeries), such as SeriesCollection(1).NewPoint?

Thanks for any help!

Kelvin

Here is a snippet that I had in one of my files. You can probably adapt a similar procedure.
Code:
nxtSer = Worksheets(1).ChartObjects(1).Chart.SeriesCollection(2).Points.Count 'Counts existing data series points.
 If nxtSer > 0 And nxtSer < 12 Then 'Makes sure at least one exists but does not exceed the chart parameter.
            Select Case nxtSer  'Uses select case to determine which series point needs to be added to series array.
                Case 1
                    Ser = "$M$5"
                Case 2
                    Ser = "$M$7"
                Case 3
                    Ser = "$M$9"
                Case 4
                    Ser = "$M$11"
                Case 5
                    Ser = "$M$13"
                Case 6
                    Ser = "$M$15"
                Case 7
                    Ser = "$M$17"
                Case 8
                    Ser = "$M$19"
                Case 9
                    Ser = "$M$21"
                Case 10
                    Ser = "$M$23"
                Case 11
                    Ser = "$M$25"
     End Select
 End If
ch7.SeriesCollection.Extend Worksheets(1).Range(Ser) 'Adds the appropriate cell to the array for ch7 object variable.

BTW, these data points are non-contiguous, although that is inconsequential, thought I point it out.
 
Upvote 0

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
yes, there is only one series in the snippet illustrated. It just adds a data point based on the conditions in the select case. I use it to update a chart on a monthly basis. When the current month is Complete, it will add the data point for the next month. That way my chart does not have a long line across at a zero value.
 
Upvote 0

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
You're welcome and good luck.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,195,994
Messages
6,012,750
Members
441,724
Latest member
Aalbid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top