Chart formatting loop (Font Name) VBA

ckvaternik

New Member
Joined
Mar 14, 2011
Messages
1
Hey everyone,

I am trying to find resources on here (unsuccessfully) to write a VBA loop that will go through each chart on each sheet of a workbook and change the font of all labels, series, chart titles etc.

I am having trouble understanding how to write such a loop. I have tried using the recorder to help me get a basic syntax, but so far, I can't get it.

Does anyone have any ideas?

Thanks!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Code:
Sub Chanage_Chart_Fonts()

    Dim ws As Worksheet
    Dim ch As ChartObject
    Dim ser As Series
    
    For Each ws In ActiveWorkbook.Worksheets
        If ws.ChartObjects.Count > 0 Then
            For Each ch In ws.ChartObjects
            
                With ch.Chart
                
                    ' Title
                    With .ChartTitle.Font
                        .Name = "Arial"
                        .FontStyle = "Bold"
                        .Size = 11
                    End With
                    
                    ' Legend
                    With .Legend.Font
                        .Name = "Arial"
                        .FontStyle = "Regular"
                        .Size = 9
                    End With
                    
                    ' DataLabels
                    For Each ser In .SeriesCollection
                        If ser.HasDataLabels Then
                            With ser.DataLabels.Font
                                .Name = "Arial"
                                .FontStyle = "Regular"
                                .Size = 8
                            End With
                        End If
                    Next ser
                    
                End With
            Next ch
        End If
    Next ws
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,405
Messages
6,165,860
Members
451,988
Latest member
boo203

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