Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dk dk is offline
external usenet poster
 
Posts: 129
Default Changing Chart Colors

I have a stacked collumn chart and i would like to be able to change the
colour of the individual series depenind on the series name i.e. if the title
of series 1 = "fred" then change the colour to red, I have seen some
variations around the theme in the newsgroup but can't quite the the
SeriesCollection method to work can anyone help.

Thanks DK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Changing Chart Colors

DK,

Something like this perhaps,

Sub test()
Dim cx As Long
Dim was As Worksheet
Dim sr As Series
Dim cht As Chart

Set was = ActiveSheet
Set cht = ws.ChartObjects(1).Chart

For Each sr In cht.SeriesCollection
cx = 0
Select Case UCase(sr.Name)
Case "FRED"
cx = 3
Case "PAM": cx = 4
Case Else: cx = xlAutomatic
End Select
Next

End Sub

Choose your colours carefully to avoid applying similar to the default
(automatic)colours, which for fill type series are applied in series index
order starting from colorindex 17.

Regards,
Peter T

"DK" wrote in message
...
I have a stacked collumn chart and i would like to be able to change the
colour of the individual series depenind on the series name i.e. if the

title
of series 1 = "fred" then change the colour to red, I have seen some
variations around the theme in the newsgroup but can't quite the the
SeriesCollection method to work can anyone help.

Thanks DK



  #3   Report Post  
Posted to microsoft.public.excel.programming
dk dk is offline
external usenet poster
 
Posts: 129
Default Changing Chart Colors

This is how I got it working. Is there an listing of all major colours with
the appropriate number by them available?

Sub ChangeGraphColours()
Dim ch As Chart
Dim chObj As Object
Dim Sh As Worksheet
Dim Ser As Series

For Each ch In ThisWorkbook.Charts

For Each Ser In ch.SeriesCollection

Current = Ser.Name

If Current = "Fred" Then
Ser.Fill.ForeColor.SchemeColor = 26
End If

If Current = "Joe" Then
Ser.Fill.Patterned Pattern:=msoPatternWideUpwardDiagonal
Ser.Fill.ForeColor.SchemeColor = 50
Ser.Fill.BackColor.SchemeColor = 2
End If

Next Ser

Next ch

End Sub

"Peter T" wrote:

DK,

Something like this perhaps,

Sub test()
Dim cx As Long
Dim was As Worksheet
Dim sr As Series
Dim cht As Chart

Set was = ActiveSheet
Set cht = ws.ChartObjects(1).Chart

For Each sr In cht.SeriesCollection
cx = 0
Select Case UCase(sr.Name)
Case "FRED"
cx = 3
Case "PAM": cx = 4
Case Else: cx = xlAutomatic
End Select
Next

End Sub

Choose your colours carefully to avoid applying similar to the default
(automatic)colours, which for fill type series are applied in series index
order starting from colorindex 17.

Regards,
Peter T

"DK" wrote in message
...
I have a stacked collumn chart and i would like to be able to change the
colour of the individual series depenind on the series name i.e. if the

title
of series 1 = "fred" then change the colour to red, I have seen some
variations around the theme in the newsgroup but can't quite the the
SeriesCollection method to work can anyone help.

Thanks DK




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 pie chart slice colors John Charts and Charting in Excel 1 March 2nd 08 07:48 PM
Scatter Chart Changing Colors [email protected] Excel Discussion (Misc queries) 3 November 5th 07 02:39 PM
Scatter Chart Changing Colors [email protected] Charts and Charting in Excel 0 November 1st 07 01:30 PM
Changing Colors in a Bar Chart EAB1977 Charts and Charting in Excel 1 August 31st 07 06:35 PM
changing colors of slices in a pie chart mread Charts and Charting in Excel 1 June 14th 07 10:16 PM


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

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

About Us

"It's about Microsoft Excel"