Ron -
I think that's what he says already works.
Bucweat -
Try something like this:
for each oSeries in oMyChart.SeriesCollection
if oSeries.Name = "MyChartSeries" then
' do what you need to do with "MyChartSeries"
exit for
end if
next
In fact, this isn't even robust enough. I've found that doing For Each in
some collections may not actually sample each item in the collection. This
is more reliable:
for iSeries = 1 to oMyChart.SeriesCollection.Count
set oSeries = oMyChart.SeriesCollection(iSeries)
if oSeries.Name = "MyChartSeries" then
' do what you need to do with "MyChartSeries"
exit for
end if
next
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
>>Hi,
>>
[quoted text clipped - 39 lines]
> ======================
> --ron
bucweat - 21 Mar 2008 16:37 GMT
Hi Jon,
Thanks...I actually had something like the first block of code in mind
as a workaround, but given what you said I will try something more
along the lines of the second block of code.
Just wondering...have you used SeriesCollection(index) where index is
a name successfully with 2007?
charlie
> Bucweat -
>
[quoted text clipped - 20 lines]
>
> - Jon
Jon Peltier - 22 Mar 2008 04:53 GMT
I haven't done too much in 2007, but I've tested plenty of existing code,
and I don't recall this being an issue.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
Hi Jon,
Thanks...I actually had something like the first block of code in mind
as a workaround, but given what you said I will try something more
along the lines of the second block of code.
Just wondering...have you used SeriesCollection(index) where index is
a name successfully with 2007?
charlie
> Bucweat -
>
[quoted text clipped - 20 lines]
>
> - Jon
Ron Rosenfeld - 22 Mar 2008 00:51 GMT
>Ron -
>
>I think that's what he says already works.
<xx> (sound of hand slapping forehead). Of course, I misread.
This seems to work in 2007:
-------------------
Sub foo()
Dim oSeries As Object
Dim oMychart As Chart
Set oMychart = Worksheets("sheet1").ChartObjects(1).Chart
Set oSeries = oMychart.SeriesCollection("C1")
Debug.Print oSeries.Name
End Sub
----------------------------
Where "C1" is a valid name.
--ron