GiraffetheGeek
Board Regular
- Joined
- May 25, 2011
- Messages
- 58
Hi there,
I have a spreadsheet in which I have a graph.
At the moment the chart is only made up of for lines of data, but as time goes on this will increase.
I want the chart to update as time goes on so I have devised this peice of code to update the source data for the chart.
I get the error "Run-time error '1004' Unable to set the Values property of the Series class.
I sorta got out of my depth with this, but thought I might be able to teach myself something. Looks like not
Can anyone help?
I have a spreadsheet in which I have a graph.
At the moment the chart is only made up of for lines of data, but as time goes on this will increase.
I want the chart to update as time goes on so I have devised this peice of code to update the source data for the chart.
Code:
Sub FormatChart()
Sheets("ChartData").Select
Range("A1").Select
If ActiveCell <> "" Then
Do Until ActiveCell.Value = ""
ActiveCell.Offset(0, 1).Select
Loop
End If
ActiveCell.Offset(0, -1).Select
endrow = ActiveCell.Row
Sheets("Running Results").Select
ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Values = "='ChartData'!$B$1:$B$" & endrow
ActiveChart.SeriesCollection(2).Values = "='ChartData'!$E$1:$E$" & endrow
ActiveChart.SeriesCollection(3).Values = "='ChartData'!$H$1:$H$" & endrow
ActiveChart.SeriesCollection(4).Values = "='ChartData'!$K$1:$K$" & endrow
ActiveChart.SeriesCollection(5).Values = "='ChartData'!$N$1:$N$" & endrow
End Sub
I get the error "Run-time error '1004' Unable to set the Values property of the Series class.
I sorta got out of my depth with this, but thought I might be able to teach myself something. Looks like not
Can anyone help?