In my excel workbook, my waterfall chart axis values change based on the values in two cells.
I have constrained my users to using a set cell as the lower value and another as the higher value.
The problem is, they do not know which project value is lower or higher until they have selected it from a dropdown and see what value gets pulled in from another worksheet.
What I would like is for an IF
statement to figure out which of the two values is larger and assign that value as the maximum value and the other as the minimum value.
My code:
Sub Worksheet_Calculcate()
Dim objCht As ChartObject
For Each objCht In Sheets("Price Bridge Chart").ChartObjects
With objCht.Chart
' Value (Y) Axis
With .Axes(xlValue)
.MaximumScale = ActiveSheet.Range("$D$68").Value + 500000
.MinimumScale = ActiveSheet.Range("$C$68").Value - 500000
' .MajorUnit = ActiveSheet.Range("$K$3").Value / 10 'Chart horizontal lines
.MajorUnit = (.MaximumScale - .MinimumScale) / 10
End With
End With
Next objCht
End Sub
I would probably have to add two additional variables but am trying to make the solution as simple as possible.