Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Koreef
 
Posts: n/a
Default Changing the color of a Series Collection using visual basic?

I am trying to change the color of a Series Collection using visual basic. I
have tried things like "Chart(1).SeriesCollection(2).Points.Interior.Colo r =
3" among many others, if you could give me any help I would appreciate it.

Thanks


  #2   Report Post  
John Mansfield
 
Posts: n/a
Default

Koreef,

The examples below assume you are working with embedded charts:

To change all of the series colors for all charts in a worksheet (edit out
the markers if you don't want them):

Sub LoopSeries()
Dim ws As Worksheet
Dim ct As ChartObject
Dim ser As Series
For Each ws In Worksheets
For Each ct In ws.ChartObjects
For Each ser In ct.Chart.SeriesCollection
ser.Border.ColorIndex = 3
ser.MarkerForegroundColorIndex = 3
ser.MarkerBackgroundColorIndex = 3
Next ser
Next ct
Next ws
End Sub

If you just want to do one chart, you can activate it by clicking on it
once. Then run this:

Sub LoopSeries()
Set cht = ActiveChart
Set Srs = cht.SeriesCollection
For Each Sr In Srs
Sr.Border.ColorIndex = 3
Next Sr
End Sub

Another option that goes after the first chart in the workbook:

Sub LoopSeries()
Set cht = ActiveSheet.ChartObjects(1).Chart
Set Srs = cht.SeriesCollection
For Each Sr In Srs
Sr.Border.ColorIndex = 3
Next Sr
End Sub

Finally, use this logic to go after a named embedded chart:

Sub LoopSeries()
Set cht = ActiveSheet.ChartObjects("Chart 1")
Set Srs = cht.Chart.SeriesCollection
For Each Sr In Srs
Sr.Border.ColorIndex = 3
Next Sr
End Sub

Please post back if you are referring to chart sheets.

----
Regards,
John Mansfield
http://www.pdbook.com


"Koreef" wrote:

I am trying to change the color of a Series Collection using visual basic. I
have tried things like "Chart(1).SeriesCollection(2).Points.Interior.Colo r =
3" among many others, if you could give me any help I would appreciate it.

Thanks


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
Changing "Series" Name jerry chapman Charts and Charting in Excel 3 April 23rd 23 11:45 AM
How to add series with VBA? deko Charts and Charting in Excel 0 March 8th 05 02:05 AM
Two bars for a Chart with a Secondary Axis GregBausman Charts and Charting in Excel 3 March 1st 05 11:03 PM
Dynamic series in Chart Jeff Charts and Charting in Excel 2 February 24th 05 11:54 AM
Quickly Changing Several Series to Appear the Same Barb Reinhardt Charts and Charting in Excel 2 February 7th 05 03:10 PM


All times are GMT +1. The time now is 03:21 PM.

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"