Legend Members
Use the Legend object to format or move a legend or to get the individual entries from the legend. Use the Chart object’s Legend property to get a reference to this collection. The Legend object has the following members. Key members (shown in bold) are covered in the following reference section:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Be sure to set the Chart object’s HasLegend property to True before using this object. The following code moves a chart’s legend to the left side and sets its background color:
Sub LegendMembers( )
Dim chrt As Chart, lg As Legend
' Get the chart.
Set chrt = ActiveChart
' Make sure chart has a legend.
chrt.HasLegend = True
' Get the legend.
Set lg = chrt.Legend
' Set the position.
lg.Position = xlLegendPositionLeft
' Change the background color.
lg.Interior.Color = &HFFFF00
End SubBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access