I can't test it on this computer, but try:
RowNum = ActiveSheet.Range("D2").Value
ActiveSheet.ChartObjects("Prob").Activate
ActiveChart.SeriesCollection(1).XValues = "=prob!R1C1:R" & RowNum & "C1"
ActiveChart.SeriesCollection(1).Values = "=prob!R1C2:R" & RowNum & "C2"
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
"nsv" wrote in message
...
I have the following lines of code in a macro:
ActiveSheet.ChartObjects("Prob").Activate
ActiveChart.SeriesCollection(1).XValues = "=prob!R1C1:R45C1"
ActiveChart.SeriesCollection(1).Values = "=prob!R1C2:R45C2"
I want the number of chart data rows (in this example it is 45) to be
variable so that this value is taken from a cell in the sheet, but it
will not accept a variable name here.
Is this possible?
NSV
--
nsv
------------------------------------------------------------------------
nsv's Profile:
http://www.excelforum.com/member.php...o&userid=26500
View this thread: http://www.excelforum.com/showthread...hreadid=487226