Aja -
Let's try it another way. I think you are running out of chartobjects.
Sub macrotitlesize()
dim cho as chartobject
For each cho in activesheet.chartobjects
With cho.Chart
.Axes(xlCategory).MajorUnitScale = xlYears
.Axes(xlCategory).MinorUnitScale = xlMonths
.Axes(xlCategory).Crosses = xlCustom
.Axes(xlCategory).AxisBetweenCategories = True
.Axes(xlCategory).ReversePlotOrder = False
.Axes(xlCategory).MinimumScale = "1/1/2000"
.Axes(xlCategory).MaximumScaleIsAuto = True
.Axes(xlCategory).MajorUnit = 1
.Axes(xlCategory).MinorUnitIsAuto = True
.Axes(xlCategory).MinorUnit = 1
.Axes(xlCategory).CrossesAt = "1/1/2000"
End With
Next
End Sub
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
Aja wrote:
I am attempting to give all of my charts the same scale and font size using a Macro. When I attempt to run the following code, it breaks after a few iterations and then says that it is 'Unable to get the chartobjects property of the worksheetclass'
What's wrong?
Sub macrotitlesize()
For i = 0 To 12
ActiveSheet.ChartObjects(i + 1).Activate
ActiveChart.Axes(xlCategory).MajorUnitScale = xlYears
ActiveChart.Axes(xlCategory).MinorUnitScale = xlMonths
ActiveChart.Axes(xlCategory).Crosses = xlCustom
ActiveChart.Axes(xlCategory).AxisBetweenCategories = True
ActiveChart.Axes(xlCategory).ReversePlotOrder = False
ActiveChart.Axes(xlCategory).MinimumScale = "1/1/2000"
ActiveChart.Axes(xlCategory).MaximumScaleIsAuto = True
ActiveChart.Axes(xlCategory).MajorUnit = 1
ActiveChart.Axes(xlCategory).MinimumScale = "1/1/2000"
ActiveChart.Axes(xlCategory).MaximumScaleIsAuto = True
ActiveChart.Axes(xlCategory).MinorUnitIsAuto = True
ActiveChart.Axes(xlCategory).MinorUnit = 1
ActiveChart.Axes(xlCategory).CrossesAt = "1/1/2000"
Next i
End Sub