Peter has attended:
Excel VBA Advanced course
Charts Formatting
when trying to change colors of seriescollections is it possible to dynamically determine the number of sereis collections to avoid trying to change a collection that does not exist?
RE: Charts Formatting
Hi Peter
Thanks for your question
As discussed I will generate the code required to do this and then post it to this thread. I will do this within the next few days
Regards
Stephen
RE: Charts Formatting
Hi Peter
Sorry for the delay in responding
The trick is to use the count method of the seriescollection object. The following code demos this by assigning it to a variable and presenting it in a message box.
Sub ChartsSeries()
On Error Resume Next
Dim aChart As Chart
Dim SeriesCount As Integer
Set aChart = Charts.Add
With aChart
.SetSourceData Sheets(1).Range("A1:D4"), xlColumns
SeriesCount = .SeriesCollection.Count
MsgBox SeriesCount
End With
End Sub
Hope this is useful,please follow up if you have any further questions
Regards
Stephen