+ Reply to Thread
Results 1 to 3 of 3

Dynamically change x & y axis mins and maxs based on dynamically changing data?

  1. #1
    Registered User
    Join Date
    08-05-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    9

    Dynamically change x & y axis mins and maxs based on dynamically changing data?

    Using Excel 365.

    I have a set of data to be plotted, but the data range changes dynamically based on some user-inputs. The graph changes accordingly but the x and y axis min and max values do not. Depending on the user-inputs the graph displays very squashed looking data or only a fraction of the data. I need to find a way to have the graph's x and y axis min and max values changes with the data. If the graph's inputs for min and max axis values allowed me to input standard Excel formulas, this would be a trivial problem. Please see below for more details. Any advice or suggestions is appreciated!

    Dynamic Graph Axes_Question.png

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,208

    Re: Dynamically change x & y axis mins and maxs based on dynamically changing data?

    A simple example in the attachment. Moment refresh the chart depends on the solutions used in the actual workbook. It is difficult to say anything more from the pictures.
    An example for version 365. Other versions may lack the formulas used.

    Artik
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-05-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    9

    Re: Dynamically change x & y axis mins and maxs based on dynamically changing data?

    Artik,

    Thank you for the example to work through. It got me on the right track and ultimately to my solution. I ended up with the following code to change two charts with one on-click macro.

    ///////

    Option Explicit

    Sub xDavgBoth()

    With Charts(1).Axes(xlCategory)
    .MinimumScale = Sheets("Calculations").Range("F9").Value
    .MaximumScale = Sheets("Calculations").Range("F8").Value
    .MajorUnit = ((Sheets("Calculations").Range("F8").Value - Sheets("Calculations").Range("F9").Value) / 10)
    End With

    With Charts(1).Axes(xlValue)
    .MinimumScale = Sheets("Calculations").Range("H9").Value - (Sheets("Calculations").Range("H8").Value - Sheets("Calculations").Range("H9").Value) / 3
    .MaximumScale = Sheets("Calculations").Range("H8").Value + (Sheets("Calculations").Range("H8").Value - Sheets("Calculations").Range("H9").Value) / 3
    .MajorUnit = (Sheets("Calculations").Range("H8").Value - Sheets("Calculations").Range("H9").Value) / 3
    End With

    Sheets("Interactive Still").Select
    ActiveSheet.ChartObjects("Chart 37").Activate
    ActiveChart.Axes(xlCategory).MinimumScale = Sheets("Calculations").Range("F9").Value
    ActiveChart.Axes(xlCategory).MaximumScale = Sheets("Calculations").Range("F8").Value
    ActiveChart.Axes(xlCategory).MajorUnit = ((Sheets("Calculations").Range("F8").Value - Sheets("Calculations").Range("F9").Value) / 10)
    ActiveChart.Axes(xlValue).MinimumScale = Sheets("Calculations").Range("H9").Value - (Sheets("Calculations").Range("H8").Value - Sheets("Calculations").Range("H9").Value) / 3
    ActiveChart.Axes(xlValue).MaximumScale = Sheets("Calculations").Range("H8").Value + (Sheets("Calculations").Range("H8").Value - Sheets("Calculations").Range("H9").Value) / 3
    ActiveChart.Axes(xlValue).MajorUnit = (Sheets("Calculations").Range("H8").Value - Sheets("Calculations").Range("H9").Value) / 3

    End Sub

+ 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] How can I dynamically change the format of the Y axis based on the source data
    By rmeister29 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 05-13-2023, 04:10 AM
  2. Change chart price data dynamically based on user selection
    By Luu4466 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-16-2020, 06:26 AM
  3. SOLVED-Dynamically change size/range of x axis of chart
    By helpme858 in forum Excel General
    Replies: 2
    Last Post: 08-07-2017, 12:20 PM
  4. Dynamically change data based on parameters
    By MrWicked in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-07-2015, 04:47 AM
  5. [SOLVED] Dynamically change X-axis as per dropdown selection
    By Sai Prashanth in forum Excel General
    Replies: 3
    Last Post: 09-12-2014, 05:20 PM
  6. Change the range in x axis dynamically for line chart
    By dimwit in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-27-2013, 05:23 AM
  7. Calculating MEDIAN based on dynamically changing range
    By L.LEE in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-06-2013, 05:31 AM

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