LegendEntry Object

Description

Represents a legend entry in a chart legend.

Each legend entry has two parts: the text of the entry, which is the name of the series associated with the legend entry; and an entry marker, which visually links the legend entry with its associated series or trendline in the chart. Formatting properties for the entry marker and its associated series or trendline are contained in the LegendKey object.

The text of a legend entry cannot be changed. LegendEntry objects support font formatting, and they can be deleted. No pattern formatting is supported for legend entries. The position and size of entries is fixed.

Accessors

The LegendEntry object is a member of the LegendEntries collection. The LegendEntries collection contains all the LegendEntry objects in the legend.

To access a single member of the collection, use the LegendEntries method with the index number of the legend entry as an argument. You cannot access 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. The following example changes the font for the text of the legend entry at the top of the legend (this is usually the legend for series one).


Worksheets("sheet1").ChartObjects(1).Chart _
    .Legend.LegendEntries(1).Font.Italic = True

Remarks

There is no direct way to access the series or trendline corresponding to the legend entry.

Once legend entries have been deleted, the only way to restore them is to remove and recreate the legend that contained them by setting the HasLegend property for the chart to False and then back to True.

Properties

Application Property, Creator Property, Font Property, Index Property, LegendKey Property, Parent Property.

Methods

Delete Method, Select Method.