Thread: Dynamic Charts
View Single Post
  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

Your syntax is wrong. Remove the last quote:

activechart.setsourcedata source:=sheets(custname).range("c1:d" & lr),
plotby:=xlcolumns

But this kind of thing can be done without using VBA. You can create a
named range with a formula that detects the number of rows, and adjusts
accordingly:

http://peltiertech.com/Excel/Charts/Dynamics.html

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


vrk1 wrote:

I have a 2 column data set that I need to chart. The last row of this
dataset can increase or decrease. I need the chart to reflect the values
dynamically.

For this, I am calculating the last row value in the macro and transferring
it to the variable "lr".

When I try to introduce the value of lr in the following statement and run
it, I get an error "Run-time error '1004': Method 'run' of object
'_application' failed"

activechart.setsourcedata source:=sheets(custname).range("c1:d" & lr & "),
plotby:=xlcolumns


Does anyone know how to resolve this problem?