+ Reply to Thread
Results 1 to 7 of 7

Variable minimum and maximum axis values?

  1. #1
    Registered User
    Join Date
    03-10-2014
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    70

    Variable minimum and maximum axis values?

    Hello all,

    I have 2 charts on top of eachother - an area graph and column chart. I need them to match up on the x axis, meaning, meaning the bar charts start at 0 on the area graph. I can do this by setting the axis minimum and maximum of the column chart to -55 and 55, or -45 and 45.

    Is there some way to set these maximum and minimum axis values equal to a cell on the sheet, or a formula? If I set them to 'auto' they won't always be equal to one another.

    Thanks
    Last edited by HalPlz; 10-08-2015 at 04:57 PM.

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

    Re: Variable minimum and maximum axis values?

    It can be done using VBA, but not without VBA. I do not know how knowledgeable you are about VBA as a programming language or Excel's object model, so I will first refer you to the axis object members: https://msdn.microsoft.com/EN-US/lib.../ff195770.aspx Your main interest for this will be the "maximumscale" and "minimumscale" properties.

    Basic code structure would look something like:
    Please Login or Register  to view this content.
    The procedure can be run from the change or calculate event if desired or attached to a button of some kind or other variations.

    Does that help?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: Variable minimum and maximum axis values?

    Have a look also on a bit longer description: http://peltiertech.com/link-excel-ch...lues-in-cells/
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    03-10-2014
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Variable minimum and maximum axis values?

    Thanks for this.

    I now have 2 charts - how do I specify each chart in VBA?

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

    Re: Variable minimum and maximum axis values?

    I will refer you again to the help files that describe Excel's object model. If the charts are in stand-alone chart sheets, you will need the charts collection to specify which chart you want. If you are referring to 2 charts embedded in a worksheet, then you will need the Chartobjects object/collection. In my or Jon's sample code, replace "activechart" with the appropriate "charts(item)" or "chartobjects(item)"
    object model: https://msdn.microsoft.com/en-us/lib.../ff194068.aspx
    charts collection/object: https://msdn.microsoft.com/EN-US/lib.../ff193297.aspx
    chargobjects collection/object: https://msdn.microsoft.com/EN-US/lib.../ff822178.aspx

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Variable minimum and maximum axis values?

    if two charts on worksheets

    Please Login or Register  to view this content.
    Last edited by humdingaling; 10-09-2015 at 02:02 AM. Reason: updated with code
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Variable minimum and maximum axis values?

    if you have both primary and secondary axis and want to use cells to set the axis
    below code

    Please Login or Register  to view this content.
    replace H1/H2 with whatever cell you want to use

+ 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. Replies: 2
    Last Post: 07-14-2014, 11:11 AM
  2. VBA to set Minimum and Maximum Values of X Axis
    By astha.malik1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2014, 04:42 AM
  3. linking maximum and minimum y axis values to a cell value
    By randor in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-15-2013, 08:12 PM
  4. Replies: 10
    Last Post: 10-07-2013, 11:41 AM
  5. Charts: Format Axis -> Axis Options -> Fixed minimum and maximum
    By johnmata in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-28-2013, 05:53 PM
  6. Replies: 1
    Last Post: 12-15-2012, 11:32 AM
  7. Replies: 1
    Last Post: 02-12-2010, 05:03 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