+ Reply to Thread
Results 1 to 9 of 9

Changing colour of multiple series

  1. #1
    Registered User
    Join Date
    10-16-2014
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    5

    Changing colour of multiple series

    Hi all,

    I am trying to change the colour of multiple series on a graph so that it changes from blue to red.
    My current code works but if i change the number of series then I would have to change the whole code.

    Please Login or Register  to view this content.
    etc

    Thanks
    Last edited by liem12345; 06-15-2017 at 12:03 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Changing colour of multiple series

    I think I have code for this already. However, it would help a lot to have a sample workbook.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    10-16-2014
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    5

    Re: Changing colour of multiple series

    I have attached the before and after excel sheet. I just want to make a gradient of colours for my series depending on the number of series.

    For instance I want series 1 to be blue and it to start to go to red or black for the final series. So the code should be independent of the number of series in a chart.

  4. #4
    Registered User
    Join Date
    10-16-2014
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    5

    Re: Changing colour of multiple series

    This is what i have so far:
    Please Login or Register  to view this content.
    When I try to run it compile error: end sub. I already have it at the end so why doesn't it work?
    Last edited by liem12345; 06-15-2017 at 11:52 AM.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Changing colour of multiple series

    In the future, use code tags:
    - They make the code easier to read in the post
    - It will keep the mods off your back. Technically speaking, we're not supposed to respond to posts that don't use tags.

    I will take a look at what you have.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Changing colour of multiple series

    Well for one thing, you have the function embedded inside the subroutine. Move it outside as indicated below. Also the row highlighted in red has an error. The term, 255 - (Number_4 * i) evaluates to a negative number. RGB doesn't like that.

    I may come up with a better scheme for you.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-16-2014
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    5

    Re: Changing colour of multiple series

    Ok, thanks I have changed the previous posts with the correct tags.

    I have changed those two errors but now the code doesn't do anything to the graphs.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Changing colour of multiple series

    Try using FullSeriesCollection instead of SeriesCollection.

    Attached is a scheme that works, You select what colors you want for the series on the Series Color Sheet. The table figures out the RGB for the filled colors.

    The code then applies the RGB to the series. I turned off some of the series so I could actually see the changes happening. Otherwise it was like looking at colored spaghetti.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-16-2014
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    5

    Re: Changing colour of multiple series

    Hi,

    Thanks for getting back to me. That code is good if I want a specific colour for a specific number of species.

    I should have desensitised the data another way to make it more obvious what I was trying to do. I am trying to make sure that if i have an unknown integer of series for a graph, I can also makes the series colour from blue to red on the RGB scale. The graph on the right is the graph before the code and the graph on the left is after the code. At the moment I have just set the values for a graph if i have 15 series in the macro CD graph, but I wish to be able to vary it with series so if i had 10 or 20 series, I could always change the colour of the series so that series 1 is blue and it gradually turns to red by series 20.
    Attached Files Attached Files

+ 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. Need way of changing graph line colour for multiple graphs
    By hunterage2000 in forum Excel General
    Replies: 2
    Last Post: 01-30-2016, 06:22 AM
  2. Changing multiple series markers on a chart
    By rhenry2424 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-20-2015, 04:45 AM
  3. Replies: 1
    Last Post: 03-05-2015, 05:30 AM
  4. Changing marker size and line width of multiple series on multiple sheets
    By kbannuru in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2014, 06:04 AM
  5. [SOLVED] Displaying multiple data series on one axis, including colour coding.
    By ATC92 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-12-2013, 06:36 AM
  6. changing row colour depending on multiple cell values
    By Erikp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2011, 06:57 PM
  7. Changing Multiple Data Series
    By Shooga in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-17-2007, 03:08 PM

Tags for this Thread

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