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

#### hedgeman50

##### Board Regular
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

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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...

Thank you very much. I'll give that a shot.

Max

Replies
2
Views
266
Replies
9
Views
518
Replies
2
Views
647
Replies
0
Views
226
Replies
3
Views
361

1,203,757
Messages
6,057,178
Members
444,911
Latest member
Uncommon1

### 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.

### Which adblocker are you using?

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

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