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:



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



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?

Was this article helpful?

0 0

Post a comment