+ Reply to Thread
Results 1 to 5 of 5

Series Colored Differently - by groups

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2017
    Location
    Bulgaria
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    3

    Series Colored Differently - by groups

    Hello All,

    I have several series (lets say 10: Series1, Series2, ....Series10) and I just want make them in two groups colored differently. For example Series from 1 to 5 to be colored in RED and Series from 6 to 10 to be colored in BLACK.
    I use "Scatter with smooth lines" for the graph.
    I used a macro code (you can see it below), but it gave a option only to change to color of all series by changing RGB value.

    Any help will be appreciated.
    Best regards
    Sub x()
        Dim objSeries As Series
        
        With ActiveChart
            For Each objSeries In .SeriesCollection
                With objSeries.Format.Line
                    .Transparency = 0
                    .Weight = 0.75
                    .ForeColor.RGB = 0
                End With
            Next
        End With
    End Sub
    Last edited by 6StringJazzer; 11-25-2017 at 05:26 PM. Reason: added CODE tags; moved from Excel Tips

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,767

    Re: Series Colored Differently - by groups

    Quote Originally Posted by Atanasi View Post
    For example Series from 1 to 5 to be colored in RED and Series from 6 to 10 to be colored in BLACK.
    I would try this. For more detailed answers that have been tested please attach file.
    Sub x()
        Dim objSeries As Series
        Dim i As Long
        
        With ActiveChart
    
            For i = 1 To 5
                With .SeriesCollection(i).Format.Line
                    .Transparency = 0
                    .Weight = 0.75
                    .ForeColor.RGB = (255, 0, 0)
                End With
            Next i
    
            For i = 6 To 10
                With .SeriesCollection(i).Format.Line
                    .Transparency = 0
                    .Weight = 0.75
                    .ForeColor.RGB = (0, 0, 0)
                End With
            Next i
    
        End With
    End Sub
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-24-2017
    Location
    Bulgaria
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    3

    Re: Series Colored Differently - by groups

    Thank you very much for the answer, but some error appeared. Error.JPG
    --> With .SeriesCollection(i).Fromat.Line
    Do you have any idea what have to be do?

  4. #4
    Registered User
    Join Date
    11-24-2017
    Location
    Bulgaria
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    3

    Re: Series Colored Differently - by groups

    Yep it works. Thank you very much

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,767

    Re: Series Colored Differently - by groups

    You can copy and paste code from posts to avoid typing errors.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to count only colored cell and extract details of colored cell's row
    By bala04msw in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-23-2016, 07:03 AM
  2. Cell colored, but not colored when printed?
    By richard11153 in forum Excel General
    Replies: 1
    Last Post: 02-08-2016, 03:23 PM
  3. Replies: 1
    Last Post: 11-09-2013, 02:43 AM
  4. Using Pivot Table Groups/Rows for separate chart series
    By AntiPop in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-09-2013, 06:40 AM
  5. How to make groups of colored bars in bar graph?
    By mlevin77 in forum Excel Charting & Pivots
    Replies: 14
    Last Post: 01-30-2013, 05:54 AM
  6. Same color for groups of series (line chart)
    By dogbiskit in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 06-20-2008, 01:01 AM
  7. Have blocks of blue colored cells ... want them surrounded by lavender-colored cells
    By rocket1406 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-01-2007, 03:59 PM

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