LegendEntries collection (Excel Graph)
A collection of all the LegendEntry objects in the specified chart legend.
Remarks
Each legend entry has two parts: the text of the entry, which is the name of the series or trendline associated with the entry; and the entry marker, which visually links the legend entry with its associated series or trendline in the chart. The formatting properties for the entry marker and its associated series or trendline are contained in the LegendKey object.
Use the LegendEntries method to return the LegendEntries collection.
Use LegendEntries (index), where index is the legend entry's index number, to return a single LegendEntry object. You cannot return legend entries by name.
The index number represents the position of the legend entry in the legend. LegendEntries(1)
is at the top of the legend; LegendEntries(LegendEntries.Count)
is at the bottom.
Example
The following example loops through the collection of legend entries in the chart and changes their font color to blue.
With myChart.Legend
For i = 1 To .LegendEntries.Count
.LegendEntries(i).Font.ColorIndex = 5
Next
End With
The following example changes the font style to italic for the text of the legend entry at the top of the legend (this is usually the legend for series one) in myChart.
myChart.Legend.LegendEntries(1).Font.Italic = True
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.