First time poster...
I have a XY Scatter Chart acting as a project timeline and want to allow individuals to zoom in on sections of the chart (Manual mode) and then switch back to the Excel auto-scale (Auto mode). I've added a tick box that when ticked it should auto-scale the chart and if un-ticked it should use values in certain cells and the chart should update as the values in the cells change.
I've got the chart on a sheet called Dashboard and the cells for the Manual mode are on a sheet called Worksheet Variables.
I've done lots of digging and playing around, but just can't seem to get it to work. I've got the code living on the Dashboard Excel Object as a Change command (don't know if that is the right place for it though).
Example: When the tick box on sheet "Dashboard" is ticked cell U2 on Worksheet Variables is True and the chart should auto-scale. If Worksheet Variables cell U2 is false then the chart should scale to the values in the sheet "Worksheet Variables" cells U7, U8, U9, V2, V3, V4 and then the chart should update as those values change.
Here's what I've got so far; any help would be brilliant!
Thanks!
I have a XY Scatter Chart acting as a project timeline and want to allow individuals to zoom in on sections of the chart (Manual mode) and then switch back to the Excel auto-scale (Auto mode). I've added a tick box that when ticked it should auto-scale the chart and if un-ticked it should use values in certain cells and the chart should update as the values in the cells change.
I've got the chart on a sheet called Dashboard and the cells for the Manual mode are on a sheet called Worksheet Variables.
I've done lots of digging and playing around, but just can't seem to get it to work. I've got the code living on the Dashboard Excel Object as a Change command (don't know if that is the right place for it though).
Example: When the tick box on sheet "Dashboard" is ticked cell U2 on Worksheet Variables is True and the chart should auto-scale. If Worksheet Variables cell U2 is false then the chart should scale to the values in the sheet "Worksheet Variables" cells U7, U8, U9, V2, V3, V4 and then the chart should update as those values change.
Here's what I've got so far; any help would be brilliant!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wsWV As Worksheet
Set wsWV = Worksheets("Worksheet Variables")
Select Case wsWV.Range("$U$2").Value
Case True
ChartObjects("Timeline").Chart.Axes(xlCategory).MaximumScaleIsAuto = True
ChartObjects("Timeline").Chart.Axes(xlCategory).MinimumScaleIsAuto = True
ChartObjects("Timeline").Chart.Axes(xlCategory).MajorUnitIsAuto = True
ChartObjects("Timeline").Chart.Axes(xlValue).MaximumScaleIsAuto = True
ChartObjects("Timeline").Chart.Axes(xlValue).MinimumScaleIsAuto = True
ChartObjects("Timeline").Chart.Axes(xlValue).MajorUnitIsAuto = True
Case Else
Case wsWV.Range("$U$7")
ChartObjects("Timeline").Chart.Axes(xlCategory).MinimumScale = Target.Value
Case wsWV.Range("$U$8")
ChartObjects("Timeline").Chart.Axes(xlCategory).MaximumScale = Target.Value
Case wsWV.Range("$U$9")
ChartObjects("Timeline").Chart.Axes(xlCategory).MajorUnit = Target.Value
Case wsWV.Range("$V$3")
ChartObjects("Timeline").Chart.Axes(xlValue).MinimumScale = Target.Value
Case wsWV.Range("$V$2")
ChartObjects("Timeline").Chart.Axes(xlValue).MaximumScale = Target.Value
Case wsWV.Range("$V$4")
ChartObjects("Timeline").Chart.Axes(xlValue).MajorUnit = Target.Value
End Select
End Sub
Thanks!