Thread: Chart Code
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Chart Code

You could use dynamic ranges, as others have suggested, or you could
properly reference the ranges for the .Values property of the series by
including the sheet name.

ActiveChart.seriescollection("HAMILTON").values = "=Sheet1!R28C4:R34C4"

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"keri" wrote in message
ups.com...
Hi I am getting frustrated with the code for the chart as below.
I want the chart series data source to change depending on a checkbox
linked to a cell. However I seem to have a problem with the line that
changes the values. (I recorded the original code from a macro). I have
tried naming the series collection by number but this doesn't work
either. When I step through the code and get to either of the lines
that say " ......values = "=R" then I get a run time error 1004
application or user defined error or a run time error 438 object does
not support this property or method.


Sheets("chart").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select

If ActiveSheet.Range("a3") = True Then
ActiveChart.seriescollection("HAMILTON").Select
ActiveChart.seriescollection("HAMILTON").values = "=R28C4:R34C4"
Else: ActiveChart.seriescollection("HAMILTON").values =
"=R2C2:R20C2"

I'd appreciate any advice anyone can give me as to where I am going
wrong. Thanks.