Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Source data for chart


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Source data for chart

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Source data for chart

I have a similar question. In my case I want to highlight the xy
values for the chart, then chart the data on a scatter plot. The data
are surrounded by other populated columns - so CurrentRegion won't
work. The problem in the skinnied-down macro below is the Range
function takes the hard coded range. How do I pass in the
user-selected range?

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B4:C10")
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Source data for chart

Dim rSelection As Range
If TypeName(Selection) = "Range" Then
Set rSelection = Selection
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=rSelection
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
Else
MsgBox "Select a range and try again", vbCritical
Exit Sub
End If

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


wrote in message
ups.com...
I have a similar question. In my case I want to highlight the xy
values for the chart, then chart the data on a scatter plot. The data
are surrounded by other populated columns - so CurrentRegion won't
work. The problem in the skinnied-down macro below is the Range
function takes the hard coded range. How do I pass in the
user-selected range?

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B4:C10")
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Source data for chart


Thanks Jon, but it doesn't work. The compiler only reads:

ActiveChart.SeriesCollection(1).XValues = "=prob!R1C1:R"

and the rest of the line is turned into rubbish, but I will try what
can do with the other example.

NS

--
ns
-----------------------------------------------------------------------
nsv's Profile: http://www.excelforum.com/member.php...fo&userid=2650
View this thread: http://www.excelforum.com/showthread.php?threadid=48722

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Include info from data source in data table but not in chart UHSH Admin Charts and Charting in Excel 1 February 26th 09 05:04 AM
pie chart & column chart w/same source data martymi Charts and Charting in Excel 2 May 1st 07 04:25 PM
Excel chart source data y-values can only accept 7 data pts? progprog Charts and Charting in Excel 3 March 14th 07 01:09 AM
Use detailed data in one worksheet to create summary data as chart source rdemyan Charts and Charting in Excel 0 January 23rd 07 02:18 PM
How do you link chart source data when you copy the chart? mamagirl Charts and Charting in Excel 1 December 8th 06 02:40 AM


All times are GMT +1. The time now is 01:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"