Changing the font size of Axis Tick Labels in a Pivot Chart

curtishavak

New Member
Joined
May 31, 2012
Messages
41
Does anyone know how (or if) I can change the default font size of the tick labels on the vertical axis in a Pivot Chart? This is easy to do in a standard chart, but for some reason, the option isn't presented (at least not obviously) on a PivotChart.

I searched the interwebs and found the below bit of code and tried it, but it gave an error:

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">With ActiveChart.Axes(xlCategory).TickLabels.Font
'.Bold = msoTrue
.Size =18
EndWith</code>

Any ideas?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,

You need a space between End and With:
Rich (BB code):
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">With ActiveChart.Axes(xlCategory).TickLabels.Font
        '.Bold = msoTrue
        .Size =18
End With


Which reminds me of the old joke about there being too much space between pig and and and and and whistle. :)

Pig-and-Whistle-sign-1987-Grafty-Green.jpg

</code>
 
Upvote 0
Well now I just feel kinda silly... Sometimes you just need a fresh pair of eyes.

I'll test and see if that does the trick.
 
Upvote 0
Well, it sort of worked. I'm using a format with a data table at the bottom of the chart. When I run the macro, the height of the box containing the primary horizontal axis labels increases, but the font of the labels themselves don't change size.

So, any other ideas?

Also, I don't want to change the font size of the horizontal axis, but of the primary and secondary axes. I'm not familiar with the VBA to define which axis I want to change.
 
Upvote 0
To find how Excel does it try using the macro recorder.

Switch it on.
Make the change.
Switch it off.
Look at the code produced.

changed the x-axis then the y-axis and got this:
Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveChart.Axes(xlCategory).Select
    Selection.Format.TextFrame2.TextRange.Font.Size = 24
    ActiveChart.Axes(xlValue).Select
    Selection.Format.TextFrame2.TextRange.Font.Size = 16
End Sub
 
Upvote 0
Good idea...it's been a while for me since the last time I wrote a macro. Forgot about that nifty tool.

I recorded a macro on a standard chart and got the same code. Then tried running it on a pivot chart and it gave me an error.

Then, EUREKA! I happened to glance at the Home Ribbon while I had an axis selected and the Font options and noticed they weren't grayed out. I increased the font size in the ribbon and it worked!

Didn't see the forest for the trees...

Thanks for the help, Rick!
 
Upvote 0
No problem. I am glad you got it sorted in the end.

Thanks for letting me know.

Regards,
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

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