D
DCSwearingen
Is there a way to change chart parameters without actually selecting th
sheet or activating the chart?
I have about 160 individual charts on three worksheets.
I know I can set Application.ScreenUpdating = False as a last resort.
Here is the basic structure for updating one chart's parameters.
Sub SetAxesValues()
Dim cMin, cMax
cMax = Sheets("Electric").Range("A3").Value
cMin = Sheets("Electric").Range("A4").Value
Sheets("Electric").Select
ActiveSheet.ChartObjects("PotElectRoll").Activate
With ActiveChart.Axes(xlValue)
.MinimumScale = cMin
.MaximumScale = cMax
.MinorUnit = (cMax - cMin) / 25
.MajorUnit = (cMax - cMin) / 5
End With
cMin = Sheets("Electric").Range("A5").Value
cMax = Sheets("Electric").Range("A6").Value
With ActiveChart.Axes(xlCategory)
.MinimumScale = cMin
.MaximumScale = cMax
End With
End Sub
Can the two lines selecting the sheet and activating the chart b
replaced by
wrapping the rest of the routine in a With / End With construction?
I just can't seem to find the syntax... The following doesn't work.
With Sheets.ChartObjects("PotElectRoll")
...
End Wit
sheet or activating the chart?
I have about 160 individual charts on three worksheets.
I know I can set Application.ScreenUpdating = False as a last resort.
Here is the basic structure for updating one chart's parameters.
Sub SetAxesValues()
Dim cMin, cMax
cMax = Sheets("Electric").Range("A3").Value
cMin = Sheets("Electric").Range("A4").Value
Sheets("Electric").Select
ActiveSheet.ChartObjects("PotElectRoll").Activate
With ActiveChart.Axes(xlValue)
.MinimumScale = cMin
.MaximumScale = cMax
.MinorUnit = (cMax - cMin) / 25
.MajorUnit = (cMax - cMin) / 5
End With
cMin = Sheets("Electric").Range("A5").Value
cMax = Sheets("Electric").Range("A6").Value
With ActiveChart.Axes(xlCategory)
.MinimumScale = cMin
.MaximumScale = cMax
End With
End Sub
Can the two lines selecting the sheet and activating the chart b
replaced by
wrapping the rest of the routine in a With / End With construction?
I just can't seem to find the syntax... The following doesn't work.
With Sheets.ChartObjects("PotElectRoll")
...
End Wit