Dynamic Axes for Chart(s)

N4nninga

New Member
Joined
Dec 5, 2017
Messages
2
Hi,

On Worksheet 1 I have 2 different graphs for which I would like the minimum and maximum scale to be dynamic. This goes for both the X and the Y axis. The minimum and maximum scale that I would like to use are calculated in cells on Worksheet 2.

Could anyone help me out on this one? Thanks in advance
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the Board


Code:
' Sheet2 module
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ch1 As Chart, ch2 As Chart
If Not Intersect(Target, Me.[b10:e11]) Is Nothing Then
    Set ch1 = Sheets("sheet1").ChartObjects(1).Chart
    Set ch2 = Sheets("sheet1").ChartObjects(2).Chart
    
    ch1.Axes(xlCategory).MinimumScale = Me.[b10]
    ch1.Axes(xlCategory).MaximumScale = Me.[c10]
    ch1.Axes(xlValue).MinimumScale = Me.[d10]
    ch1.Axes(xlValue).MaximumScale = Me.[e10]
        
    ch2.Axes(1).MinimumScale = Me.[b11]
    ch2.Axes(1).MaximumScale = Me.[c11]
    ch2.Axes(2).MinimumScale = Me.[d11]
    ch2.Axes(2).MaximumScale = Me.[e11]
        
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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