Format Axes font by VBA

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
I'm trying to change the color of my embedded chart font to white, but even recording it gives something weird as the result and when I try to execute that, it gives an error. Here's what the recording gives:

Code:
    ActiveSheet.ChartObjects("EmbeddedChart").Activate
    ActiveChart.SeriesCollection(2).DataLabels.Select
    With Selection.Format.TextFrame2.TextRange.Font
        .BaselineOffset = 0
        .Fill.Visible = msoTrue
        .Fill.ForeColor.ObjectThemeColor = msoThemeColorBackground1
        .Fill.ForeColor.TintAndShade = 0
        .Fill.ForeColor.Brightness = 0
        .Fill.Transparency = 0
        .Fill.Solid
    End With

Which one of those is the actual font color? I would like to perform the whole system with one line, something like:
ActiveSheet.ChartObjects("EmbeddedChart").SeriesCollection(2).DataLabels.Format.TextFrame2.TextRange.Font.ForeColor.RGB = RGB(255,255,255)

It also seems like Excel doesn't like the .Axes(xlCategory).Format part and I can't even find the Format property from anywhere but the recorded code (tried for example MSDN). What's the way to access the font?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi Jaymond

This works for me:

Code:
With ActiveSheet.ChartObjects("EmbeddedChart").Chart
    .SeriesCollection(1).DataLabels.Font.Color = vbGreen
    .Axes(xlCategory, xlPrimary).TickLabels.Font.Color = vbGreen
End With
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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