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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

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
 
Upvote 0

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?
 
Upvote 0

Forum statistics

Threads
1,186,918
Messages
5,960,568
Members
438,486
Latest member
ncc84330

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