Possible to have chart y-axis scale min = Cell C27?

hedgeman50

Board Regular
Joined
Sep 20, 2002
Messages
76
I have a dynamic chart (i.e., updates for different data), and I can't have the y-axis minimum always equal zero (or be static, as some data has a min of 5 while other data has a min of 100).

Question: Is there a way to have the y-axis minimum equal a certain cell within a worksheet?

Thanks!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This calls for an event based procedure. The event to use is the Chart_Calculate event. I presume your chart is not an embedded chart - it is an independent chart sheet.
Do the following:
Open the workbook
Go to the Visual Basic Editor (Alt+F11)
In the Project Explorer window, activate the module for the chart sheet by dbl-clicking its icon.

Copy the following code to this module:

Private Sub Chart_Calculate()
Dim Ser As Series
YRoundedTo = 10 'Change this to the multiple (5, 25, whatever) you wish to round down to
YMin = 10 ^ 9
For Each Ser In Me.SeriesCollection
YMin1 = WorksheetFunction.Min(Ser.Values)
If YMin1 < YMin Then YMin = YMin1
Next
YMin = WorksheetFunction.Floor(YMin, YRoundedTo)
Me.Axes(xlValue).MinimumScale = YMin
End Sub

The Y-axis will scale correctly every time the chart recalculates.

If you wish to refer to a cell on the worksheet to set min of y-axis, use the following code:
(I presume the cell is named "YMin")

Private Sub Chart_Calculate()
Me.Axes(xlValue).MinimumScale = Range("YMin")
End Sub

Hope you find this of help...
 
Upvote 0

Forum statistics

Threads
1,223,304
Messages
6,171,319
Members
452,396
Latest member
ajl_ahmed

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