I would like some help with creating a script to update a chart. This is my code below with the first series being the code I thought would work and then the rest being standard Excel macro code:
Sub Adjust_Sat()
Dim ChrtEnd As Integer
Dim ChrtStart As Integer
Application.ScreenUpdating = False
Sheets("Daily").Select
Range("C76").End(xlToRight).Select
ChrtEnd = ActiveCell.Column
ChrtStart = ChrtEnd - 20
Sheets("Saturday Elapsed").Select
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(1).Values = "=Daily!R76C3" & CStr(ChrtStart) & ":R76C" & CStr(ChrtEnd)
ActiveChart.SeriesCollection(2).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(2).Values = "=Daily!R77C3:R77C39"
ActiveChart.SeriesCollection(3).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(3).Values = "=Daily!R78C3:R78C39"
ActiveChart.SeriesCollection(4).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(4).Values = "=Daily!R79C3:R79C39"
End Sub
When I try to run this I get "Run Time Error 1004, unable to set the properties value of the series class". What I am after is defining the range to only show 20 entries instead of the 30 that are there. Your help will be appreciated.
Sub Adjust_Sat()
Dim ChrtEnd As Integer
Dim ChrtStart As Integer
Application.ScreenUpdating = False
Sheets("Daily").Select
Range("C76").End(xlToRight).Select
ChrtEnd = ActiveCell.Column
ChrtStart = ChrtEnd - 20
Sheets("Saturday Elapsed").Select
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(1).Values = "=Daily!R76C3" & CStr(ChrtStart) & ":R76C" & CStr(ChrtEnd)
ActiveChart.SeriesCollection(2).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(2).Values = "=Daily!R77C3:R77C39"
ActiveChart.SeriesCollection(3).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(3).Values = "=Daily!R78C3:R78C39"
ActiveChart.SeriesCollection(4).XValues = "=Daily!R75C3:R75C39"
ActiveChart.SeriesCollection(4).Values = "=Daily!R79C3:R79C39"
End Sub
When I try to run this I get "Run Time Error 1004, unable to set the properties value of the series class". What I am after is defining the range to only show 20 entries instead of the 30 that are there. Your help will be appreciated.