Making Minimum and Maximum Values on Axis in chart Dynamic

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a stacked bar chart which is in essence a Gantt chart. I want it to work on multiple projects however for this to happen I need the Minimum values dynamic. I got the below code from another forum yet it keeps producing the following error

Run Time Error -2147467259 (80004005)':
Method of 'MinimumScale' of object Axis Failed.

Would anyone have any ideas on where I am going wrong?



Sub ScaleAxes()
With Application.ActiveChart.Axes(xlCategory, xlPrimary)
.MinimumScale = ActiveSheet.Range("F3").Value
.MaximumScale = ActiveSheet.Range("F2").Value
.MajorUnit = ActiveSheet.Range("F4").Value
End With
With Application.ActiveChart.Axes(xlValue, xlPrimary)
.MinimumScale = ActiveSheet.Range("G3").Value
.MaximumScale = ActiveSheet.Range("G2").Value
.MajorUnit = ActiveSheet.Range("G4").Value
End With
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
The only thing I can suggest is that maybe you want to use xlValue instead of xlCategory and you axes group.
 
Upvote 0
The only thing I can suggest is that maybe you want to use xlValue instead of xlCategory and you axes group.

Yep that worked perfectly thanks so much. It actually had an error for the second part with the cell G2,G3 and G4 references but I didnt need those,

thanks again
 
Upvote 0
Yep that worked perfectly thanks so much. It actually had an error for the second part with the cell G2,G3 and G4 references but I didnt need those,

thanks again

You're welcome,
regards JLG
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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