+ Reply to Thread
Results 1 to 13 of 13

VBA Chart Data Labels - Different Formatting for Value and Percentage

  1. #1
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    VBA Chart Data Labels - Different Formatting for Value and Percentage

    Is there a way to have separate formatting for the label value and the label percentage?

    I would like the value to be bold, the percentage to be not bold.

    As a starting point, this is the code so far:

    Please Login or Register  to view this content.
    Last edited by AliGW; 03-16-2024 at 01:08 AM. Reason: Code tags added - please review the forum guidelines.

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

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Welcome to the Forum briskie!

    Can you attach a file with data so that we can see the chart that is generated by this code, and test solutions?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    190

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    HI
    I think it can't be done (and I hope to be proven wrong) but it would be better to "see" your file, not just the code.

    Hi,
    Mario

  4. #4
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Hi 6StringJazzer,

    thank you for the warm welcome!

    I have attached two test files.

    The first one with the "simple" code without any further font formatting.

    The second file has some added code, which comes close to the idea..
    Attached Files Attached Files

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

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    There is only one attachment. Perhaps you selected both in the same operation and overwrote the first attachment, rather than uploading a second one.

    All of the labels selected have the same font properties. I was trying to create a second copy of the same series and configure different labels, hoping they could be overlaid on the first set. Although the Chart Design Data shows a second series, it is not visible in the chart, so I am stuck for now. If I do it manually it doesn't show the second series, and if I do it in the code, the code runs but also does not show the second series.

    Also there is no need to put an End statement in this code.
    Last edited by 6StringJazzer; 03-16-2024 at 11:16 AM.

  6. #6
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    The second file:

    And the third file:

    The third file has the second series plotted (another set of percentages).
    Attached Files Attached Files
    Last edited by briskie; 03-16-2024 at 12:03 PM.

  7. #7
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    This works (!), the Category Name is Red and Bold, the Percentage is Black and not Bold.
    So the question is: how to combine these two codes?
    Attached Files Attached Files
    Last edited by briskie; 03-16-2024 at 12:35 PM.

  8. #8
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    190

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Hi
    Try this macro
    Please Login or Register  to view this content.
    I'm happy to have been proven wrong

    Hi,
    Mario

  9. #9
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Hi Mario,
    wow, very nice – but ;-)
    I really need to have the first code doing the actual labeling first (adding the labels with the cells font color).
    Then this second code as a bonus, which only tells the percentage "Bold=False".
    Do you see any possibility of combining these?
    Please have a look: The first file only contains the labeling code, that's the starting point.
    The second file contains both, the labeling code and the one you successfully tweaked.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    190

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Hi
    Try this new macro
    Please Login or Register  to view this content.
    Hi,
    Mario

  11. #11
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Hi Mario,

    wow, truly amazing!

    Two last questions, if I may:

    1.
    How do I get:
    Category Name > new line
    Category Value > new line
    Category Percentage

    2.
    Where can I insert the Percentage Number Format “0,00%”

    I’m playing around, but can’t work it out yet (I just started using VBA a week ago).

    Best,
    Toni

  12. #12
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    190

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    HI
    I have been studying Excel Charts for several years but, as I said before, I didn't know that part of the content of the Label could be colored differently. There is always more to learn!
    Regarding your first question (showing data on different lines) modify the part of code like this
    Please Login or Register  to view this content.
    For the other question I have no solution. I can't advise you on how to also show the decimal part of the percentage.
    I would be happy with what I got.
    Hello and happy studying VBA,
    Mario

  13. #13
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Chart Data Labels - Different Formatting for Value and Percentage

    Hi Mario,
    thank you so much for your effort, its really great, that it actually works this far!
    I will post another question regarding the Number Format, maybe somebody has an idea.
    (Unfortunately I need the 2 decimals).
    Thanks a lot!
    Toni

+ 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. Replies: 0
    Last Post: 05-13-2019, 08:08 PM
  2. Formatting Data Labels in chart
    By GregM56 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2018, 09:53 AM
  3. Pivot chart stacked, axis in values labels in percentage
    By rpinxt in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 11-01-2016, 03:42 PM
  4. Conditional formatting chart data labels?
    By -AJ- in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-24-2014, 11:48 PM
  5. Formatting Row Labels in Pivot Table/Chart
    By Pauleyb in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-30-2014, 04:53 PM
  6. Conditionally formatting Chart Labels?
    By compulsiveguile in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-17-2008, 09:38 AM
  7. Formatting all data labels on a chart at once
    By VancitysFinest in forum Excel General
    Replies: 1
    Last Post: 02-09-2006, 07:50 AM

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