View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Setting chart Xvalue errors

The limit is not 10. It depends on the length of the string used to define
the range. His code falls down for other reasons.

Your examples put the values of the indicated cells into a string array,
without preserving links to the original cells. This is fine if the chart is
a one-off and you don't worry about data changing.

The only way inserting a space and a close parenthesis into your string
would work is if the string were somehow missing these characters. The last
line you suggest fails, but this doesn't fail:

activechart.SeriesCollection(1).XValues =
"$H$1,$J$1,$L$1,$N$1,$P$1,$R$1,$T$1,$V$1,$X$1"

It doesn't do as desired, however, as it uses the cell addresses in the
string array, not the values in the cells, as the labels for the category
axis. It converts the entry in the Category Labels box of the Source Data -
Series dialog into exactly what Robert posted.

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


"Greg Glynn" wrote in message
oups.com...
Robert,

I've struck this problem before also. I think there is limit of 10
ranges you can nominate, so check that first. Your code ={"$H$1","$J
$1","$L$1","$N$1","$P$1","$R$1","$T$1","$V$1","$X$ 1"} only has 9, so
it's probably OK.

The code that worked for me was:

myxvalues = myxvalues & Cells(1, (x * 4)).Value & ","

ActiveChart.SeriesCollection(1).XValues = " " & myxvalues & ")"

That's right! A LEADING SPACE and a TRAILING )

(Don't ask me why it works though).

So try .SeriesCollection(1).XValues = " " & "$H$1","$J$1","$L$1","$N
$1","$P$1","$R$1","$T$1","$V$1","$X$1" & ")"

Let me know how you go.