+ Reply to Thread
Results 1 to 10 of 10

Macros for multiple graphs

  1. #1
    Registered User
    Join Date
    11-21-2006
    Posts
    8

    Macros for multiple graphs

    I currently have a 70 page spreadsheet with similar data that needs representing in pie chart format. All the column headers are the same and I only need 2 columns (A and T). There are however different numbers of rows. Is it possible to write a macro to detect the number of rows before it draws the relevant pie chart (I've managed the pie chart bit!!)

    See attached example, same concept but cant post real data.

    Cheers

    Jeremy
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jeremy,

    Add a Standard VBA Module to your workbook. Copy and paste the code below into it. This should get you going.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    11-21-2006
    Posts
    8

    Macros for graph part 2

    I have pasted as suggested, but it just comes up with the dialogue box saying no chart objects. What do I have to change to get the pie charts to draw when I run the macro?? I have assigned macro to the smilie button in the chart toolbar.

    Cheers

    Jez
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jeremy,

    I wasn't sure if you wanted the macro to create the charts. Form your post you seemed to iindicate that you had the charts created. No problem. I can easilty change the macro to create the charts also.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    11-21-2006
    Posts
    8

    Multiple graphs

    I have recorded a macro for drawing a pie chart but I am not sure which bits of code I need to keep and which to delete when I tie it in with what you have sent me?

    See attached

    regards

    Jez
    Attached Files Attached Files

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jeremy,

    Copy this code into your macro module. If the chart doesn't exisit, it will create it. If you want to change the Pie Chart format, let me know.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    11-21-2006
    Posts
    8

    Multiple graphs

    Leith,

    Thank you very much for helping me. The code you sent me works perfectly on the test, however how do I get it to plot data that is not in next door columns eg A and V??

    Regards

    Jeremy

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jeremy,

    Sorry about not changing that for you. Here is the revised macro. The line that was changed is marked in red.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  9. #9
    Registered User
    Join Date
    11-21-2006
    Posts
    8

    Multiple graphs

    Thanks very much Leith, works perfectly. Is there any way to get it to not add the legend to the pie chart?

    Regards

    Jeremy

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jeremy,

    Yes, the legend can be removed . I have added it to code here for you.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 03-12-2007 at 06:26 PM.

+ 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