Modifying chart properties Free VBA Excel @ ExcelOptimize.Com

Modifying chart properties


The following example changes the Legend font for all charts on the active sheet. It uses a For-Next loop to process all ChartObject objects:
Sub LegendMod()
Dim cht As ChartObject
For Each cht In ActiveSheet.ChartObjects
With cht.Chart.Legend.Font
.Name = “Calibri”
.FontStyle = “Bold”
.Size = 12
End With
Next cht
End Sub

Note that the Font object is contained in the Legend object, which is contained in the Chart object, which is contained in the ChartObjects collection. Now do you understand why it’s called an object hierarchy?

Related Post

Leave a Reply