+ Reply to Thread
Results 1 to 9 of 9

Increase/decrease chart size on double-click

  1. #1
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Increase/decrease chart size on double-click

    I would like to be able to have my charts increase/decrease their size by a factor of two when I double-click on them.
    So the first double-click would double its size and the second double-click would return its size to its original.

    But the macro would need to keep track of each chart, because I have more than a dozen, and it would need to remember
    which state/size each chart was in.

    Can anybody help me out with this?

  2. #2
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Increase/decrease chart size on double-click

    Hi ChrisXcel,

    Maybe something like this:

    Please Login or Register  to view this content.
    you can assign the macro to the chart itself and it will be a single click instead of double, double opens the property menu


    Joske
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  3. #3
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Increase/decrease chart size on double-click

    Quote Originally Posted by Joske920 View Post
    Hi ChrisXcel,

    Maybe something like this:

    Please Login or Register  to view this content.
    you can assign the macro to the chart itself and it will be a single click instead of double, double opens the property menu


    Joske
    Thanks for helping Joske!

    I tried your code but there are a few problems right now.

    First of all, I would need to know the chart name of each of my charts for the code to work.
    The charts are deleted each day with new ones replacing them.

    Secondly, when I ran the code manually after changing the starting sizes (width and height) to what
    was assigned to the chart, the code jumped to the 'Else' section, without doubling the chart size!

  4. #4
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Increase/decrease chart size on double-click

    The following code worked to make one chart bigger:

    Please Login or Register  to view this content.
    But here are the problems:

    1. I had to know the name of the chart beforehand "Chart 599", for it to work.
    2. The names of the charts change each time the VBA code is run each day with new data.
    The VBA code creates new charts each day with the new names.

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

    Re: Increase/decrease chart size on double-click

    If you want to use the doubleclick event you will need to use a class object to enable the capture of the event for dynamic objects.

    Once the newly create charts are available run the code to create a collection of object to capture the event and resize the chart

    Module code
    Please Login or Register  to view this content.
    class CChtEvt code
    Please Login or Register  to view this content.

    If your charts are on multiple sheets or actual chart sheets the same class code can be used but you will need to extend the EnableAllChartEvents routine to find the relevant charts.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Increase/decrease chart size on double-click

    Quote Originally Posted by Andy Pope View Post
    If you want to use the doubleclick event you will need to use a class object to enable the capture of the event for dynamic objects.

    Once the newly create charts are available run the code to create a collection of object to capture the event and resize the chart

    Module code


    class CChtEvt code

    If your charts are on multiple sheets or actual chart sheets the same class code can be used but you will need to extend the EnableAllChartEvents routine to find the relevant charts.
    Hi Andy thanks very much for helping me out.

    Your code is working beautifully!

    There's just one little problem that hopefully you can fix for me.
    When I double click on a chart it doubles in size, as desired and when I double click again it goes back to the original size.
    That's working great.

    But at the same time, a box pops up with the following info:

    Format Chart Area:
    Patterns/Font/Properties
    OK/Cancel

    This is the Format box that would pop up normally without your code, when you double-click on any chart.

    How can I suppress that pop-up?

  7. #7
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Increase/decrease chart size on double-click

    Well I found a temporary fix/workaround.
    I inserted a SendKeys ("{ESC}") command at the end of the code.

    It takes care of the pop-up box (gets rid of it).
    However there is a bit of an annoying ghost blinking that occurs when this happens.

    I tried to take care of that with
    Application.ScreenUpdating = False
    Application.ScreenUpdating = True

    But that hasn't helped.

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

    Re: Increase/decrease chart size on double-click

    Just set the Cancel argument in the event to True

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Increase/decrease chart size on double-click

    Quote Originally Posted by Andy Pope View Post
    Just set the Cancel argument in the event to True

    Please Login or Register  to view this content.
    Thanks very much Andy!
    That seems to have done the trick.

+ 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. How do I double click a bar in a bar chart and make another bar chart?
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-08-2016, 11:43 AM
  2. Changing cell properties with double click, then revert with another double click
    By mweber2525 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-01-2014, 01:40 PM
  3. [SOLVED] Increase size of bar width within chart area
    By drinkmorewine in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2013, 03:44 PM
  4. Replies: 3
    Last Post: 09-18-2012, 01:01 AM
  5. Increase / decrease font size dependant upon number of decimal places
    By spoursy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-31-2012, 03:35 PM
  6. [SOLVED] Wrap Text, decrease font size and increase row height.
    By Robotacha2010 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2012, 07:53 PM
  7. Charts - can't increase chart size within window
    By blastboy88 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-16-2007, 09:57 PM

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