View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.charting
Jerry W. Lewis
 
Posts: n/a
Default Help with macro to assign min and max to x-axis

Sub Macro1()
minim = Range("param!i35").Value2
maxim = Range("param!i45").Value2
For Each ch In ActiveSheet.ChartObjects
ch.Activate
With ActiveChart.Axes(xlCategory)
.MinimumScale = minim
.MaximumScale = maxim
End With
Next
ActiveWindow.Visible = False
Windows(ActiveWorkbook.Name).Activate
ActiveCell.Select
End Sub

Jerry

Sinus Log wrote:

After a lot of search, I managed to do this:

Sub Macro1()
minim = Range("param!i35").Value2
maxim = Range("param!i45").Value2
ActiveSheet.ChartObjects("Chart 7491").Activate
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScale = minim
.MaximumScale = maxim
End With
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
End Sub

The workbook contains many graphs:
- 1 sheet with 1 scatter graph
- 1 sheet with 8 scatter graphs
- 4 sheets with 2 3D-graphs and 23 scatter graphs each
- a couple of sheets without graphs

There are three things I don't know how to do:
1) To assign the same minimum and maximum to the x-axes of all the
scatter graphs in one shot.
2) To change the names of the graphs ("Chart 7491" is awkward).
3) To unselect the graphs after the execution of the macro (I have to
press Escape, or else any movement of the cursor would drag the graph).

Any help would be much appreciated.