![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:56 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com