+ Reply to Thread
Results 1 to 4 of 4

Change default chart in a macro to prevent run time error when creating a pivot charts

  1. #1
    Registered User
    Join Date
    04-25-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    91

    Change default chart in a macro to prevent run time error when creating a pivot charts

    Hello,

    I am creating a macro to make a pivot chart. The issue is that when someone sets their default charts/graphs to be a scatter plot the macro returns a runtime error because the pivot table data cannot generate a scatter plot. How do you specify that the pivot chart needs to be an "xlColumnStacked" to ensure the runtime error does not occur?

    My initial thinking was that you could specify a change to the default chart prior to creating the pivot chart in the macro but I have been unable to find a solution to do this.

    Please note that i am making this macro for persons not familiar with macros and they may not know how to change the default chart setting. Ultimately they will not know that the issue is their default chart setting. My goal is to just prevent this scenerio in the first place and have the macro work on anyone's laptop with no issues regardless of their settings.

    Any help would be appreciated.

    Please Login or Register  to view this content.
    Last edited by herbie226; 05-14-2013 at 10:07 AM.

  2. #2
    Registered User
    Join Date
    04-25-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Change default chart in a macro to prevent run time error when creating a pivot charts

    Bumping to the top. If anyone needs anymore information to help answer my question please let me know!

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

    Re: Change default chart in a macro to prevent run time error when creating a pivot charts

    set the chart type on the addchart method.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    04-25-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: Change default chart in a macro to prevent run time error when creating a pivot charts

    Works great thank you! I was not sure how to designate to create the "xlColumnStacked" chart. I tried different variations but could not get it to work. Great help.

    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