View Single Post
  #2   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

You need to declare your variable As Series, not As SeriesCollection, and
loop through each series in the chart's SeriesCollection:

Dim xSer As Series
For Each xSer In aChart.SeriesCollection

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


"Robert H" wrote in message
ps.com...
sorry to be bugging the group so mych about charts but Im getting my
butt kicked. The new problem is this:

Building a column chart and needing to add the series x axis labels
which are set in VBA with
.SeriesCollection(#).XValues for each series. I need to set them all
to a named range(the same range of cells)
Im working with: some code removed for clearity)

Dim aChart As Chart
Dim shtNm As String
shtNm = ActiveSheet.Name

Set aChart = Charts.Add
Set aChart = aChart.Location(Whe=xlLocationAsObject,
Name:=shtNm)

Dim xSer As SeriesCollection
For Each xSer In aChart
.XValues = Range("code")
Next

I can set each series individuly but I need to set them as one because
the number of series is variable and can change each time the macro
runs. The named range "CODE" is always the correct size to match the
number in the series.

is there a way to make this work?
Thanks
Robert