Set Chart axis by cell values

Brian F

Active Member
Joined
Aug 31, 2009
Messages
256
Using Excel 2010. I have a table of data and a chart reflecting that data. The macro below follows the process of adjusting the minimum and maximum values of the "x" axis to -2.5 min. and 2.5 max. and the "y" axis to -3.5 min. and 3.5 max. How do I reference a cell value for the min. and max. in each case rather than the fixed values of -2.5 and 2.5 etc. That is, I want to put the min. and max values in a cell in the worksheet and have them utilized as the axis values. Any help would be greatly appreciated.

Sub xyPlane_XandY_Axis()

ActiveSheet.Shapes.Range(Array("Group 6")).Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.HasAxis(xlValue) = True
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = -2.5
ActiveChart.Axes(xlCategory).MaximumScale = 2.5
ActiveChart.HasAxis(xlValue) = True
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = -3.5
ActiveChart.Axes(xlValue).MaximumScale = 3.5

End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try like this

Code:
ActiveChart.Axes(xlCategory).MinimumScale = Sheets("Sheet1").Range("A1").Value
 
Upvote 0
Thank you Vog, that worked perfectly and solved what had been a big problem for me.

Thank you so much!
 
Upvote 0
Thank you VoG, that worked perfectly and solved what had been a big problem for me.

Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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