+ Reply to Thread
Results 1 to 3 of 3

Changing Chart Colors

Hybrid View

  1. #1
    DK
    Guest

    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. #2
    Peter T
    Guest

    Re: 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" <DK@discussions.microsoft.com> wrote in message
    news:1661D3C4-3131-4176-9986-8A6463702E5B@microsoft.com...
    > 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. #3
    DK
    Guest

    Re: 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" <DK@discussions.microsoft.com> wrote in message
    > news:1661D3C4-3131-4176-9986-8A6463702E5B@microsoft.com...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1