Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - SeriesCollection.Index

I'm getting an error using the following code - seems like I can't use .Index
with the SeriesCollection... Is that right?

If so, what should I be using?

Thanks in advance

Trevor
---------------------------------------

ActiveSheet.ChartObjects("Chart 1").Activate

sCount = ActiveChart.SeriesCollection.Count
xCount = sCount / 2 + 1

For Each mySeries In ActiveSheet.ChartObjects("Chart
1").Chart.SeriesCollection
If mySeries.Index xCount Then
mySeries.Delete
End If
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2002 - SeriesCollection.Index

Dim nSRcountOrig As Long, nSRreqd As Long

nSRcountOrig = ActiveChart.SeriesCollection.Count
nSRreqd = nSRcountOrig / 2 + 1

For i = nSRcountOrig To nSRreqd Step -1
ActiveChart.SeriesCollection(i).Delete
Next

Not sure which integers you want with "/2"

try this -

dim a as long, b as long
for i = 1 to 20
a = i / 2 +1
b = i \ 2 +1
debug.? i,a,b
next

Regards,
Peter T











"Trevor Williams" wrote in
message ...
I'm getting an error using the following code - seems like I can't use

..Index
with the SeriesCollection... Is that right?

If so, what should I be using?

Thanks in advance

Trevor
---------------------------------------

ActiveSheet.ChartObjects("Chart 1").Activate

sCount = ActiveChart.SeriesCollection.Count
xCount = sCount / 2 + 1

For Each mySeries In ActiveSheet.ChartObjects("Chart
1").Chart.SeriesCollection
If mySeries.Index xCount Then
mySeries.Delete
End If
Next



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - SeriesCollection.Index

Hi Peter

Thanks for the response - I originally tried using a loop that you have
supplied but hit problems as i went from the required series to the total
series... never thought about stepping backwards!

Am I right that you can't use .Index with the SeriesCollection?

Thanks again.

Trevor

"Peter T" wrote:

Dim nSRcountOrig As Long, nSRreqd As Long

nSRcountOrig = ActiveChart.SeriesCollection.Count
nSRreqd = nSRcountOrig / 2 + 1

For i = nSRcountOrig To nSRreqd Step -1
ActiveChart.SeriesCollection(i).Delete
Next

Not sure which integers you want with "/2"

try this -

dim a as long, b as long
for i = 1 to 20
a = i / 2 +1
b = i \ 2 +1
debug.? i,a,b
next

Regards,
Peter T











"Trevor Williams" wrote in
message ...
I'm getting an error using the following code - seems like I can't use

..Index
with the SeriesCollection... Is that right?

If so, what should I be using?

Thanks in advance

Trevor
---------------------------------------

ActiveSheet.ChartObjects("Chart 1").Activate

sCount = ActiveChart.SeriesCollection.Count
xCount = sCount / 2 + 1

For Each mySeries In ActiveSheet.ChartObjects("Chart
1").Chart.SeriesCollection
If mySeries.Index xCount Then
mySeries.Delete
End If
Next




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2002 - SeriesCollection.Index

Am I right that you can't use .Index with the SeriesCollection?

..Index, a word preceded with a dot, is not a property but you could use
..Item(index-number)
With some types of collection you can return .Index as the index number of a
referenced item in the collection, though not with Series

When deleting items of any kind of collection, in this case series in a
Seriescollection, always loop backwards. If you particularly need to loop
forwards and you want to delete say items 4 to 6 -

for i = 1 to (6-4+1)
somecollection.Delete(4)
next

I can't think of an example why you would need to loop forwards but maybe
the above shows what's going on, ie each time you delete a given index all
subsequent decrement by one.

Regards,
Peter T

"Trevor Williams" wrote in
message ...
Hi Peter

Thanks for the response - I originally tried using a loop that you have
supplied but hit problems as i went from the required series to the total
series... never thought about stepping backwards!

Am I right that you can't use .Index with the SeriesCollection?

Thanks again.

Trevor

"Peter T" wrote:

Dim nSRcountOrig As Long, nSRreqd As Long

nSRcountOrig = ActiveChart.SeriesCollection.Count
nSRreqd = nSRcountOrig / 2 + 1

For i = nSRcountOrig To nSRreqd Step -1
ActiveChart.SeriesCollection(i).Delete
Next

Not sure which integers you want with "/2"

try this -

dim a as long, b as long
for i = 1 to 20
a = i / 2 +1
b = i \ 2 +1
debug.? i,a,b
next

Regards,
Peter T











"Trevor Williams" wrote in
message ...
I'm getting an error using the following code - seems like I can't use

..Index
with the SeriesCollection... Is that right?

If so, what should I be using?

Thanks in advance

Trevor
---------------------------------------

ActiveSheet.ChartObjects("Chart 1").Activate

sCount = ActiveChart.SeriesCollection.Count
xCount = sCount / 2 + 1

For Each mySeries In ActiveSheet.ChartObjects("Chart
1").Chart.SeriesCollection
If mySeries.Index xCount Then
mySeries.Delete
End If
Next






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
XL2002 SUM with a twist... Trevor Williams Excel Worksheet Functions 4 December 9th 09 10:28 AM
xl2002: Position Picture in SeriesCollection Trevor Williams Excel Programming 10 October 23rd 07 04:02 PM
xl2002 problem Gary Keramidas Excel Programming 3 May 24th 07 04:18 AM
Using min and max function XL2002 Extremely Aggravated Excel Worksheet Functions 1 September 23rd 05 06:29 PM
SeriesCollection Varun[_2_] Excel Programming 1 July 28th 04 01:49 AM


All times are GMT +1. The time now is 08:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"