Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Include info from data source in data table but not in chart | Charts and Charting in Excel | |||
pie chart & column chart w/same source data | Charts and Charting in Excel | |||
Excel chart source data y-values can only accept 7 data pts? | Charts and Charting in Excel | |||
Use detailed data in one worksheet to create summary data as chart source | Charts and Charting in Excel | |||
How do you link chart source data when you copy the chart? | Charts and Charting in Excel |