Modifying 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 = "Arial"

.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?

0 0

Post a comment