Monday, August 26, 2019

vba - Link Excel Chart Axis Scale to Values in Cells

I have this Gantt Chart and i'm looking at Planned Vs Actual dates.
the problem is that the chart wont sync the start/end date.



i'm trying to link the max/min values to the cell with VBA but it wont to it.



I tried to use this site:
https://peltiertech.com/link-excel-chart-axis-scale-to-values-in-cells/



but his code doesn't work for my chart.




here is a picture:
enter image description here



the dates MUST be the same, and change together if i change some values in the table on the right
any ideas?
thanks



Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet.ChartObjects("Chart 2").Chart
Select Case Target.Address


Case "$G$161"
.Axes(xlCategory).MaximumScale = Target.Value

Case "$F$163"
.Axes(xlCategory).MinimumScale = Target.Value

Case "$G$161"
.Axes(xlValue).MaximumScale = Target.Value


Case "$F$163"
.Axes(xlValue).MinimumScale = Target.Value

End Select
End With
End Sub

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...