+ Reply to Thread
Results 1 to 9 of 9

Excel pie chart - fix pie colour by category name

  1. #1
    Registered User
    Join Date
    04-11-2016
    Location
    Melbourne
    MS-Off Ver
    2013
    Posts
    18

    Excel pie chart - fix pie colour by category name

    Hey guys,

    Another question here regarding the pie charts in excel.

    I'm building a list of charts with 18 categories in one pie each. The category names are the same however the value/piece of pie size varies. Now when I select the data for each new chart, the color reassigns so there is absolutely no consistency.

    Is there a way I can lock the color by name like category name, John/Jane/Brian and then list of values? This way I can easily show whose value has changed. Now all the colours are not consistent (Jane has 18 different colours in 18 different charts since the orders/values have changed).

    Thanks!

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

    Re: Excel pie chart - fix pie colour by category name

    It took some looking up and macro recording but here it is.

    First of all there are two tables:

    Table_Colors (Columns K:O) – this table assigns colors to the people. Fill Column L with the color you want, and Columns M:O will compute the RGB values for the color.

    Table_Charts (Columns Q:R) – this table enumerates the chart names and on what sheets those charts appear.

    These charts can be moved to another sheet as long as they maintain the chart names.

    Otherwise there are three sample charts.

    The macro name is set charts. It will synchronize the charts to the colors in Table_Colors.
    Attached Files Attached Files
    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
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Excel pie chart - fix pie colour by category name

    In "cleaning up" the code, I accidentally deleted a declaration of a variable so the previous version yields an error.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-11-2016
    Location
    Melbourne
    MS-Off Ver
    2013
    Posts
    18

    Re: Excel pie chart - fix pie colour by category name

    Quote Originally Posted by dflak View Post
    In "cleaning up" the code, I accidentally deleted a declaration of a variable so the previous version yields an error.
    Hey dfalk,

    Thanks so so much for your input!

    I will run the macro sometime this week and see if I can embed it into my spreadsheet this weekend.

    I will keep it updated and let you know how I go.

    Thanks again!

    Frankximus

  5. #5
    Registered User
    Join Date
    07-07-2015
    Location
    sydney
    MS-Off Ver
    ms013
    Posts
    1

    Re: Excel pie chart - fix pie colour by category name

    Quote Originally Posted by dflak View Post
    In "cleaning up" the code, I accidentally deleted a declaration of a variable so the previous version yields an error.
    Hey dfalk,

    Your codes are absolutely amazing!

    Thanks heaps!

  6. #6
    Valued Forum Contributor
    Join Date
    05-11-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    586

    Re: Excel pie chart - fix pie colour by category name

    Hi,

    Unfortunately, if you sort the "values" to Largest to smallest, the colours for each person changes

    Regards

    peterrc

  7. #7
    Registered User
    Join Date
    08-01-2016
    Location
    Southern California
    MS-Off Ver
    2016
    Posts
    4

    Re: Excel pie chart - fix pie colour by category name

    You'll need to sort the entire tables contents if you want the data to "remain" with each name. Highlight the entire table and resort by name, descending order and my charts don't change their colors with respect to the name.

  8. #8
    Registered User
    Join Date
    08-01-2016
    Location
    Southern California
    MS-Off Ver
    2016
    Posts
    4

    Re: Excel pie chart - fix pie colour by category name

    However, when I attempt to copy the macro over to my worksheet I get this:

    For Each cl In Range("Table_Charts[Charts]")

    as an error message from Excel.

    Any assistance would be appreciated.

  9. #9
    Registered User
    Join Date
    02-14-2020
    Location
    Europe
    MS-Off Ver
    2016
    Posts
    1

    Re: Excel pie chart - fix pie colour by category name

    Hi, I'm new here and didn't want to open a new thread for the same issue. Sadly the sample excel sheet doesn't work with Office 2016
    Before asking too many questions, I wanted to try it by myself using that sheet. Is it corrupted or is it just Office 2016?

+ 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. [SOLVED] Summing by colour and category
    By dna247 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-30-2015, 06:59 AM
  2. How to Chart values for Division vs Category and Sub-Category?
    By rahulgk in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 06-11-2013, 06:33 AM
  3. Replies: 2
    Last Post: 09-14-2012, 04:31 AM
  4. Bar Chart - how to colour specific category axis values.
    By Richard Buttrey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2010, 08:58 AM
  5. Replies: 1
    Last Post: 03-04-2010, 03:20 PM
  6. label the category axis from 0 to 30, step 5 in an excel chart
    By johnny hanlon in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-28-2006, 08:15 PM
  7. [SOLVED] Excel: Can I change Chart-title/category/value from a sheet-cell?
    By femke in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 10-24-2005, 12:05 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