Chart Setting Xvalues

  • Thread starter Thread starter Nigel
  • Start date Start date
N

Nigel

Hi All
I am havig some problems when setting the xvalues for a chart. The data is
stored in a named range (data), the xvalues are in the same range (column
1). The problem arises in that the the numer of rows in the range can vary
so the xvalues must also change.
I have overcome the source data by making reference to the range name (see
below) but I have not been able to figure out what I need to do for the
xvalues which are recorded as a R1C1 reference in the following code.

What code do I need to put in to make it universal in relation to my varying
data range?

TIA
Nigel

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("data"),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R4C1:R21C1"
 
The documentation for XValues says it will accept a range.

You should be able to do something like:
ActiveChart.SeriesCollection(1).XValues = Sheets("Sheet1").Range("xvalues")

If not, please let me know the error message
Also supply a bit more information about the type of chart and the ranges


Nigel said:
Hi All
I am havig some problems when setting the xvalues for a chart. The data is
stored in a named range (data), the xvalues are in the same range (column
1). The problem arises in that the the numer of rows in the range can vary
so the xvalues must also change.
I have overcome the source data by making reference to the range name (see
below) but I have not been able to figure out what I need to do for the
xvalues which are recorded as a R1C1 reference in the following code.

What code do I need to put in to make it universal in relation to my varying
data range?

TIA
Nigel

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("data"),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R4C1:R21C1"




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top