Format chart axis options by cell reference? Is it possible?

frabulator

Board Regular
Joined
Jun 27, 2014
Messages
249
Office Version
  1. 2019
Platform
  1. Windows
So I know this is possible through VBA, but I would like an option to to create a dynamic scatter plot that changes the axis options to automatically adjust to the values specified in a cell.
Like I said, VBA it is entirely possible, but I would like this to be an option with just formulas/values/referencing. Is this possible?

Thanks,
Frab
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi,
You can test Named Ranges ...
see:
Not exactly what I was looking for.

That will update the values in a range that is being graphed. IE: set the graph to plot a range, change the values in the range, values in graph changes.

I was wondering if I could update the distance that is being plotted/shown. For instance, can I specify that C2 is going to be the Minimum X Axes value while C3 is the Maximum X Axes value?

In VBA it is pretty simple, just manually change it to whatever. I could also work the long way around and reduce the values being plotted by the range that I am wanting to limit.

Is it possible to do this with just a cell reference?
 
Upvote 0
I'm not a VBA expert. But, if you don't mind VBA to start you could put the options that vba would use in cells on the worksheet and then use the worksheet change event to adjust the chart options when any of those cells change.
 
Upvote 0
I'm not a VBA expert. But, if you don't mind VBA to start you could put the options that vba would use in cells on the worksheet and then use the worksheet change event to adjust the chart options when any of those cells change.
Yes you can. In fact, here is an example of how that can be done.

The below will gather the current min/max, resize them, and then populate the min/max back to original.

VBA Code:
Sub whatis()

    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.PlotArea.Select
    Dim os As Double
    os = ActiveChart.Axes(xlValue).MinimumScale
    Dim ot As Double
    ot = ActiveChart.Axes(xlCategory).MinimumScale
    
    For i = 1 To 25
        DoEvents
        
        Dim dp As Double
        dp = i
        ActiveChart.Axes(xlValue).MinimumScale = dp * -1
        ActiveChart.Axes(xlValue).MaximumScale = dp
        
        dp = i
  
    Next
    
    ActiveChart.Axes(xlValue).MinimumScale = os
    ActiveChart.Axes(xlValue).MaximumScale = os * -1
    
    
    ActiveChart.Axes(xlCategory).MinimumScale = ot
    ActiveChart.Axes(xlCategory).MaximumScale = ot * -1
End Sub

Like I said, I can do it in VBA, but can I do it without?
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top