+ Reply to Thread
Results 1 to 2 of 2

How do i get the Y axis min and max to be dynamic

Hybrid View

  1. #1
    Registered User
    Join Date
    12-10-2013
    Location
    Oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    5

    How do i get the Y axis min and max to be dynamic

    I need my chart to change the min and max values dynamically.
    I have data that goes out of the range of my chart so i can not use the auto in axis options.

    I have inserted this code
    PHP Code: 
    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Address
        
    Case "$G$13"
            
    ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlValue_
                
    .MaximumScale Target.Value
        
    Case "$F$13"
            
    ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlValue_
                
    .MinimumScale Target.Value
        
    Case "$H$13"
            
    ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlValue_
                
    .MajorUnit Target.Value
        
    Case Else
    End Select
    End Sub 
    It works if i manually change it but not when it is automatically updated by changing the pn in the dropdown menu on d1
    This is for an automated system so needs to work without user input.

    Thanks in advance for any input.
    I have gotten this far using this forums help and user input.
    Attached Files Attached Files

  2. #2
    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,863

    Re: How do i get the Y axis min and max to be dynamic

    You probably gave too little detail to have your problem properly addressed.
    Here is my guess:
    Formulae in G1 and H1 show what you really would like to have as Min and Max for your axis - it is only my guess - you haven't said it.
    No guesses how MajorUnit shall be determined. (may be it is enough to change only max and min, and have majorunit automatic?)

    What event shall be "trigger" for the update - here you gave good suggestion:
    "automatically updated by changing the pn in the dropdown menu on d1"

    Try the folowing code instead (not together with) previous:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Address
     Case "$D$1"
       ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlValue) _
         .MaximumScale = Range("H1").Value
       ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlValue) _
         .MinimumScale = Range("G1").Value
    '   ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlValue) _
         .MajorUnit = Target.Value
    End Select
    End Sub
    As you can see i left the majorunit in the procedure - just commented it out. Once you decide where the source of it is - you can uncomment this line and put the source instead of Target.Value

+ 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. Dynamic y-Axis
    By avi3197 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-27-2013, 06:56 AM
  2. Legend Only Shows Used Axis on Dynamic Chart (X, Y and Y2 axis)
    By TEBrown in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 06-21-2012, 10:15 AM
  3. Dynamic X Axis
    By jomili in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-01-2011, 12:09 PM
  4. Dynamic x-axis
    By robert_mim in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-09-2009, 01:53 PM
  5. Dynamic Range with unused formula messing up x axis on dynamic graph
    By cabybake@yahoo.com in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-02-2006, 04:10 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