VBA to change Source Data for 1 series

Joined
Feb 8, 2002
Messages
3,041
Office Version
  1. 365
Platform
  1. Windows
I have a chart with three series.

Series 1 runs from A3:M3
Series 3 runs from A5:M5

Series 2 has to run from A4.Resize(1, x) where x changes each month.

What is the code to change just that one series?
SetSourceData affects the whole chart.

I am here in a room with only Excel 2007, where of course the macro recorder returns nothing.
Thanks in Advance!

Bill
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
3,734
This is the code the macro recorder produced when I changed the source for one range of a graph:

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 16/11/2009 by Jaap
'
'
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.SeriesCollection(2).Select
    ActiveChart.SeriesCollection(2).Values = "=Sheet1!R8C5:R10C5"
End Sub

Does that help?
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Not really adding anything here to what sijpie said but you should be able to amend the series using:

Code:
Activechart.SeriesCollection(2).Value = Range("A4").ReSize(,x)
 
Solution
Joined
Feb 8, 2002
Messages
3,041
Office Version
  1. 365
Platform
  1. Windows
Thanks.

That isn't quite doing it.

There are three series.
Series 1 is a column chart and always wants to show 12 months
Series 2 & 3 are line charts.
I want series 3 to show 12 points, but series 2 to only show the active point

(For a variety of reasons, we can not code #N/A into the future cells...)

Bill
 
Joined
Feb 8, 2002
Messages
3,041
Office Version
  1. 365
Platform
  1. Windows
Richard...
Yes - that did it. Excellent. Thanks very much.

Bill
 

Watch MrExcel Video

Forum statistics

Threads
1,130,447
Messages
5,642,209
Members
417,262
Latest member
andrewd1

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