ActiveChart.SeriesCollection(1) exsist ?

aviadht

Board Regular
Joined
Aug 7, 2008
Messages
91
Hi,

I'm writing a code that suppose to give new colors to a graph, how can i check in a ActiveChart.SeriesCollection(1) is exsist or not ?

For example: ActiveChart.SeriesCollection(1) is exsist but ActiveChart.SeriesCollection(5) sometimes is in the graph and sometimes not..

i want the vba to give a new color only if ActiveChart.SeriesCollection(5) is in the graph

Thanks,
Aviad
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi Aviad,

One way to test if a series exists is to check the SeriesCollection.Count

Code:
With ActiveChart
    If .SeriesCollection.Count >= 5 Then
       .SeriesCollection(5).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
    End If
End With
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top