View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default iterate through chart series collection

No mystery:

=SERIES(A!$A$6,A!$A$2:$A$8,A!$G$6,5)

You have seven categories but only one value, so Excel will use the first
value, and therefore only the first category.

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


"Robert H" wrote in message
ps.com...
Ive tried a few variations and have the same output on the chart but
get some interesting results watching the code

In the following the actual range is inserted in the series formula
and each series sees the full xvalue range not just its corresponding
value. As previously described, only the first label is
present, centered under the chart.

Dim xSer As Object
For Each xSer In aChart.SeriesCollection
Debug.Print "befor " & xSer.Formula
xSer.XValues = Range("code")
Debug.Print "After " & xSer.Formula
Next

output from DebugPrint
befor =SERIES(A!$A$2,,A!$G$2,1)
After =SERIES(A!$A$2,A!$A$2:$A$8,A!$G$2,1)
befor =SERIES(A!$A$3,,A!$G$3,2)
After =SERIES(A!$A$3,A!$A$2:$A$8,A!$G$3,2)
befor =SERIES(A!$A$4,,A!$G$4,3)
After =SERIES(A!$A$4,A!$A$2:$A$8,A!$G$4,3)
befor =SERIES(A!$A$5,,A!$G$5,4)
After =SERIES(A!$A$5,A!$A$2:$A$8,A!$G$5,4)
befor =SERIES(A!$A$6,,A!$G$6,5)
After =SERIES(A!$A$6,A!$A$2:$A$8,A!$G$6,5)
befor =SERIES(A!$A$7,,A!$G$7,6)
After =SERIES(A!$A$7,A!$A$2:$A$8,A!$G$7,6)
befor =SERIES(A!$A$8,,A!$G$8,7)
After =SERIES(A!$A$8,A!$A$2:$A$8,A!$G$8,7)

The next option was to use the xSer.Name instead of the CODE range
because I noticed that the values were the same. as you can see the
"after" - debug clearly shows a different value in the xvalue portion
of the formula for each series. It just so happens, these are the
correct values. Although I would prefer it the be individual ranges
rather than the values I could use this for the moment. however, when
I looked at the chart, I had the same results!!!!!!!!! only the first
label is present, centered under the chart. The resulting Category
(X) axis Label values are all {"Module 01"} even thought the xSer
formula leads me to think they should be different.

Dim xSer As Object
For Each xSer In aChart.SeriesCollection
Debug.Print "befor " & xSer.Formula
xSer.XValues = xSer.Name
Debug.Print "After " & xSer.Formula
Next

befor =SERIES(A!$A$2,,A!$G$2,1)
After =SERIES(A!$A$2,{"Module 01"},A!$G$2,1)
befor =SERIES(A!$A$3,,A!$G$3,2)
After =SERIES(A!$A$3,{"Module 02"},A!$G$3,2)
befor =SERIES(A!$A$4,,A!$G$4,3)
After =SERIES(A!$A$4,{"Module 03"},A!$G$4,3)
befor =SERIES(A!$A$5,,A!$G$5,4)
After =SERIES(A!$A$5,{"Module 14"},A!$G$5,4)
befor =SERIES(A!$A$6,,A!$G$6,5)
After =SERIES(A!$A$6,{"Module 15"},A!$G$6,5)
befor =SERIES(A!$A$7,,A!$G$7,6)
After =SERIES(A!$A$7,{"Module 28"},A!$G$7,6)
befor =SERIES(A!$A$8,,A!$G$8,7)
After =SERIES(A!$A$8,{"Module 34"},A!$G$8,7)

Stumped again!