Problem with Chart SeriesCollection
Hi,
I have a template with a number of graphs and when I run my script it is supposed to get the new range of data and sets the series of the graphs to point at the correct data.
My problem is that when the code attempts to access the series I continually receive the following error:
Quote:
Run-time error '1004'
Unable to set the Xvalues property of the series class
I have looked in the help files but cannot seem to find anything that helps.
Below is some code:
VB Code:
[INDENT]
Dim chrt As Chart, Sc As SeriesCollection
Set MyRange = Worksheets("Data_Roll").UsedRange
NoRows = MyRange.Rows.Count
Set MyRange = Worksheets("Data_Roll").Range("C3:C" & NoRows)
Set chrt = Charts("NetProfile")
Set Sc = chrt.SeriesCollection
Sc(1).XValues = MyRange[/INDENT]
Strange thing is that if I create the series manually after I have opened the template the code appears to be able to access the series object. Its as if it can't access the series objects of the series items created when the template was first built.
Does anybody have any ideas why this could be? Is it a permissions problem? Is there a better way to do this?
Any help would be much appreciated.
Many Thanks in advance.
Re: Problem with Chart SeriesCollection
Hi,
Can you hard-code it rather than trying to work out a range, i.e.
VB Code:
Charts("NetProfile").SeriesCollection(1).XValues = Worksheets("Data_Roll").Range("C3:C10")
I suspect that the answer is no. In that case, can you recreate the entire series, or add a new series? In fact, can you do anything to the graph through code at all before manually adding the series? If not, then you might be better off recreating the graphs...
...if you wanted to do the whole thing through code from the ground up, then you might want to take a look at my graphing code.
zaza
Re: Problem with Chart SeriesCollection
OK, thanks for that. Will give it a go.