none
Excel 2007: How do I change the colour, of the series line, in a line chart?

    Question

  • I'm desperately trying to change the colour, or fill, of the line in my graph, with no success.

    When I record a macro and do it, the code for doesn't show.

     

    How on earth, do I change the colour?


    Nicolai Søndergaard - LM Wind Power A/S
    Thursday, January 12, 2012 9:25 AM

Answers

  • This works for me:

       If TypeName(Selection) = "Series" Then
          Dim theLine As Excel.Series
          Set theLine = Selection
          theLine.Border.Color = RGB(2555, 0, 0)
       End If
    


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    • Marked as answer by Nicoolai Thursday, January 12, 2012 12:07 PM
    Thursday, January 12, 2012 11:31 AM

All replies

  • Hello,

    I've just recorded this macro in Excel 2010:

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.SeriesCollection(1).Select
        With Selection.Format.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 0, 0)
        End With
        With Selection.Format.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 255, 0)
            .Transparency = 0
        End With
    End Sub
    
    
    Hope this helps.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    Thursday, January 12, 2012 9:37 AM
  • Hello,

    I've just recorded this macro in Excel 2010:

     

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.SeriesCollection(1).Select
        With Selection.Format.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 0, 0)
        End With
        With Selection.Format.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 255, 0)
            .Transparency = 0
        End With
    End Sub
    
    
    Hope this helps.

     


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    I'm afraid that doesn't change anything for me :(
    Nicolai Søndergaard - LM Wind Power A/S
    Thursday, January 12, 2012 10:08 AM
  • I've reproduced this. Strange, it works when I run the code once again.
    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    Thursday, January 12, 2012 10:53 AM
  • I've reproduced this. Strange, it works when I run the code once again.
    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    In 2007 or 2010?

    We're using 2007 here, and when I record, it doesn't write anything, other than select.


    Nicolai Søndergaard - LM Wind Power A/S
    Thursday, January 12, 2012 10:55 AM
  • I see the issue in Excel 2007 SP3.
    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    Thursday, January 12, 2012 11:00 AM
  • I see the issue in Excel 2007 SP3.
    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    I have no idea where to find the good old about box, in the ribbons, so I don't know if I have SP3. 

    But what does this mean? That there is no way I can change the colours?


    Nicolai Søndergaard - LM Wind Power A/S
    Thursday, January 12, 2012 11:05 AM
  • This works for me:

       If TypeName(Selection) = "Series" Then
          Dim theLine As Excel.Series
          Set theLine = Selection
          theLine.Border.Color = RGB(2555, 0, 0)
       End If
    


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader
    • Marked as answer by Nicoolai Thursday, January 12, 2012 12:07 PM
    Thursday, January 12, 2012 11:31 AM
  • This works for me:

     

       If TypeName(Selection) = "Series" Then
          Dim theLine As Excel.Series
          Set theLine = Selection
          theLine.Border.Color = RGB(2555, 0, 0)
       End If
    

     


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Border works!

    It doesn't show up in intellisense though, so I was pretty sure it wasn't there. But just typing it out, seems to fix it.

    Thank you :)


    Nicolai Søndergaard - LM Wind Power A/S
    Thursday, January 12, 2012 12:07 PM