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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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
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,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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
Back
Top