Playing with axis scales

dangostin

New Member
Joined
Dec 7, 2010
Messages
3
Hey guys. I'm a complete newb regarding VBA. I'm trying no create a macro that can read values from cells, and change the scales in a graph according to those values. For the moment I recorded a macro while changing the min X scale, and it looks like this:

Sub TestingScale()

With ActiveChart.Axes(xlCategory)
.MinimumScale = 1
.MaximumScale = 30
.MinorUnitIsAuto = True
.MajorUnit = 1
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Windows("Tech Notes Index(4).xls").SmallScroll Down:=12
End Sub

This thing increases the X axis scale from 0 to 1. What i want to do is make the .minimumscale and .maximumscale , each read a value from 2 cells in the sheet. Those values will later be buttons, in order to increase, decrease the axis scale.

Help would be much appreciated.

Big thanks

Daniel
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
If I understand your issue correctly, the solution is (assuming that the values you want to use as min and max scale are on the "Sheet1" sheet in cells A1 and A2 respectively):
...
.MINIMUMSCALE=WORKSHEETS("SHEET1").RANGE("A1").VALUE
.MAXIMUMSCALE=WORKSHEETS("SHEET1").RANGE("A2").VALUE
...
 
Upvote 0
If I understand your issue correctly, the solution is (assuming that the values you want to use as min and max scale are on the "Sheet1" sheet in cells A1 and A2 respectively):
...
.MINIMUMSCALE=WORKSHEETS("SHEET1").RANGE("A1").VALUE
.MAXIMUMSCALE=WORKSHEETS("SHEET1").RANGE("A2").VALUE
...

In the end, i figured it out that in some way or another it has to read a value from a cell. Thanks tho' for the answer and pointing out the working sheet, wich in this case will be necessary, since a lot of ppl are going to work with this excel.

Cheers mate :)
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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