View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
DCSwearingen DCSwearingen is offline
external usenet poster
 
Posts: 1
Default Changing Chart Parameters


Is there a way to change chart parameters without actually selecting the
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 be
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 With


--
DCSwearingen

Getting old, but love computers.
------------------------------------------------------------------------
DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=568668