While using a Bar Chart as a Gantt timeline I previously was using cell values to manually update the timeline axis for Min, Max, and MajorUnit - code below where cells C3, C4, and C5 were represented respectively:
========================================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$C$4"
ActiveSheet.ChartObjects("Chart 3").Chart.Axes(xlValue) _
.MaximumScale = Target.Value
Case "$C$3"
ActiveSheet.ChartObjects("Chart 3").Chart.Axes(xlValue) _
.MinimumScale = Target.Value
Case "$C$5"
ActiveSheet.ChartObjects("Chart 3").Chart.Axes(xlValue) _
.MajorUnit = Target.Value
Case Else
End Select
End Sub
========================================
However, I now want to dynamically update the Min, Max, and MajorUnit by way of "calculated" updates. To do so I understand that the method needs to change since the present method is triggering off a cell change on the worksheet that is being entered manually. What would be the simplest way to modify the code based on a calculated change?
Note the calculation is being performed on a separate worksheet that is linked to the same C3, C4, and C5 cells where the Bar Chart is present, and the result is a calendar date - e.g. 1/23/2022.
Thank you in advance for the response!
Version: Office 365 Excel
Bookmarks