+ Reply to Thread
Results 1 to 4 of 4

Macro to set graph Y axis max and min equal to that of existing graph in worksheet

  1. #1
    Registered User
    Join Date
    12-02-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    19

    Macro to set graph Y axis max and min equal to that of existing graph in worksheet

    I need a macro code that will set the max and min Y values of a line graph equal to that of an existing graph on the worksheet that is set to auto fit the data point. For example if Graph 1 auto fits the data to Max .05 Min -.05 Y axis, i need Graph 2 to then have these values.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Macro to set graph Y axis max and min equal to that of existing graph in worksheet

    Are you familiar with Excel's object model? https://msdn.microsoft.com/EN-US/lib.../ff834649.aspx

    It should be as simple as
    1) Read the .maximumscale and .minimumscale properties of the y axis of Graph 1
    2) set the .maximumscaleisauto and .minimumscaleisauto properties of the y axis of Graph 2 to False
    3) Write the values from step 1 to the .maximumscale and .minimumscale properties of the Y axis in graph 2

    What parts of this do you need help with?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    12-02-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to set graph Y axis max and min equal to that of existing graph in worksheet

    I am not familiar. I need help with the actual code to complete steps 1-3 in your response.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Macro to set graph Y axis max and min equal to that of existing graph in worksheet

    Well, now is a good time to start to become familiar with Excel's object model. Did you look at the help file at all? Using the example given as a starting point:
    Please Login or Register  to view this content.

+ 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. [SOLVED] Second Axis for a Graph but with the same kind of graph for the two series?
    By Marceltcm in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-18-2013, 05:37 AM
  2. [SOLVED] 3 axis chart with stacked bar graph and line graph above
    By hefe_espada in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-26-2013, 12:53 PM
  3. VBA: add a series of data (Y secondary axis) to existing graph
    By sweetboy02125 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-21-2010, 06:34 AM
  4. Add secondary column graph to existing line graph
    By nbuk in forum Excel General
    Replies: 8
    Last Post: 09-02-2010, 11:49 AM
  5. Replies: 6
    Last Post: 01-25-2006, 02:45 PM

Tags for this Thread

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