Charts, Help!

cdegar01

New Member
Joined
Jan 15, 2004
Messages
30
Can anyone tell me what I'm doing wrong? I'm trying to set the font size for the axis ticklabels to 6 for every chart in the active sheet.

Sub SetFontSizeAllCharts()
Dim myCht As ChartObject
For Each myCht In ActiveSheet.ChartObjects
myCht.Chart.TickLabels.Font.Size = 6
Next
End Sub

I get errors! Help!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

CraigM

Active Member
Joined
Feb 27, 2003
Messages
320
Try this out:

Sub SetFontSizeAllCharts()
Dim myCht As ChartObject
For Each myCht In ActiveSheet.ChartObjects
myCht.Chart.Axes(xlValue).TickLabels.Font.Size = 6
myCht.Chart.Axes(xlCategory).TickLabels.Font.Size = 6
Next
End Sub
 

cdegar01

New Member
Joined
Jan 15, 2004
Messages
30
I changed the code to the following:

Sub SetFontSizeAllCharts()
Dim myCht As ChartObject
For Each myCht In ActiveSheet.ChartObjects
myCht.Chart.Axes(1).TickLabels.Font.Size = 6
Next
End Sub

But I get an error saying "Unable to get the TickLabels property of the Axis class," when I run it on a page that has about 150 charts. It works for pages with about 7 charts. What am I doing wrong?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,096
Messages
5,768,061
Members
425,451
Latest member
JohnBrooksBiddle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top