+ Reply to Thread
Results 1 to 7 of 7

macro to create pie chart based on dynamic ranges

  1. #1
    Registered User
    Join Date
    04-01-2010
    Location
    Worcester, UK
    MS-Off Ver
    Microsoft 365 (subscription)
    Posts
    50

    macro to create pie chart based on dynamic ranges

    Dear experts.

    Unfortunately my VBA knowledge is not good enough yet so I hope to get help from anyone on that forum.

    Basically what I need is a macro which will create pie graph based on dynamic ranges.

    I have inputed example workbook for better understanding what I am expecting to get + I've made example graph I would like to get.
    I got 3 tabs in my workbook - the one on which I do need graph is 'Efficiency Report'.
    In that tab I got macro which is generating table based on specified criteria.
    And from that table I do need graph.
    And because that table is generated based on criteria it might be 10 rows, 20 or 50 rows long. That's why I need automation for that graph.
    Data which I do want to graph is percentage of downtime reasons (columns L:AJ, currently row 23).
    I will appreciate any help with that.
    If someone would like to help me with it but need more info please let me know and I'll try to give as many info as required.
    Thanks in advance.
    Attached Files Attached Files
    Last edited by jarssonn; 06-05-2010 at 02:19 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: macro to create pie chart based on dynamic ranges

    Just change the formula

    L23: =IF(L21=0,NA(),L21/$K21)
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    04-01-2010
    Location
    Worcester, UK
    MS-Off Ver
    Microsoft 365 (subscription)
    Posts
    50

    Re: macro to create pie chart based on dynamic ranges

    By changing this formula you mean to avoid having a 0 on graph? Will you be able to help me with macro to create pie chart on it's own?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: macro to create pie chart based on dynamic ranges

    The formula change will get read of the datalabels for zero items, which you had a red cross through.

    To automate the chart use

    Please Login or Register  to view this content.
    And call that at the end of the CreateTable routine,

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-01-2010
    Location
    Worcester, UK
    MS-Off Ver
    Microsoft 365 (subscription)
    Posts
    50

    Re: macro to create pie chart based on dynamic ranges

    Thank you very much, macro is working well.
    I've just modify it a little bit so graph's got title and I got values and labels (categories name) shown.
    But I got only problem with one thing:
    I don't want any values and labels from values equal to 0 showing up and making the chart basically unreadable. I just need the values and labels from values greater than 0, can this be determined by macro maybe?
    I've tried to change the formula like you proposed in your first reply but this is messing the table and I think will not work about labels (categories name).
    So I will be really happy to do it by macro if possible.
    I have uploaded workbook with changes I've made so will be easy to work on that.
    I've found similar topic:
    http://www.excelforum.com/excel-char...-than-0-a.html
    but I unfortunately I can't alter the information from that topic to be useful for my problem.
    Many thanks for help.
    Attached Files Attached Files

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: macro to create pie chart based on dynamic ranges

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-01-2010
    Location
    Worcester, UK
    MS-Off Ver
    Microsoft 365 (subscription)
    Posts
    50

    Re: macro to create pie chart based on dynamic ranges

    Many thanks, you are just amazing! You do not even know how much you've helped me.
    Everything works great.
    Many thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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