Results 1 to 3 of 3

Thread: Problem with Chart SeriesCollection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    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:
    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:
    1. [INDENT]
    2. Dim chrt As Chart, Sc As SeriesCollection
    3.    
    4. Set MyRange = Worksheets("Data_Roll").UsedRange
    5. NoRows = MyRange.Rows.Count  
    6. Set MyRange = Worksheets("Data_Roll").Range("C3:C" & NoRows)
    7.        
    8. Set chrt = Charts("NetProfile")
    9. Set Sc = chrt.SeriesCollection
    10. 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.

  2. #2
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Problem with Chart SeriesCollection

    Hi,

    Can you hard-code it rather than trying to work out a range, i.e.

    VB Code:
    1. 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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Re: Problem with Chart SeriesCollection

    OK, thanks for that. Will give it a go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width