vba code to autoscale y axis

eawachte

New Member
Joined
Jan 14, 2011
Messages
29
I have a sheet that has several different series in a chart i created. i need to autoscale the y axis with the chart. The way my sheet works is I press a button and the sheet jumps to the graph.

What i would like to do is when the button is pressed to select the graph to view is add a line of code to autoscale the y axis for all series.

Do i need to create the entire graph with VBA code or can i just add a line of code to my existing macro to do that?

If what i want to do is possible what would the line of code be?

Thanks!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I have a sheet that has several different series in a chart i created. i need to autoscale the y axis with the chart. The way my sheet works is I press a button and the sheet jumps to the graph.

What i would like to do is when the button is pressed to select the graph to view is add a line of code to autoscale the y axis for all series.

Do i need to create the entire graph with VBA code or can i just add a line of code to my existing macro to do that?

If what i want to do is possible what would the line of code be?

Thanks!


this would most likely be what you are looking for:

Code:

<CODE>With Charts("Chart1")</CODE><CODE>.Axes(xlValue) </CODE>
<CODE>.MinimumScaleIsAuto = True </CODE>
<CODE>.MaximumScaleIsAuto = True</CODE>
<CODE>End With</CODE>
<CODE></CODE><CODE>Code:</CODE>
</PRE>
 
Upvote 0
I know this is an old post, but i snagged your code and it worked great, except for one problem I'm running into. Anytime the data changes in the cells that are linked to my graph, the graph then resets its y-axis and again starts at zero. The only way to get the graph to go back to using that code to change it's min/max is by using the drop down I have to change the graph away from those data points and then back to them for it to reset and use that code again to change its min/max.

Is there a way in code to have the graph refresh every time a cell changes on the chart so that it will always reference those min/max?
 
Upvote 0

Forum statistics

Threads
1,215,583
Messages
6,125,661
Members
449,247
Latest member
wingedshoes

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