View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default iterate through chart series collection

I believe you can account for the number of series being dynamic by doing
something like this:

Dim xSer As SeriesCollection
Dim i As Integer
For Each xSer In aChart
For i = 1 To xSer.Count
xSer.Item(i).XValues = Range("code")
Next i
Next


"Robert H" wrote:

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