如何使用宏更改图例条目

时间:2017-05-07 05:03:42

标签: excel-vba vba excel

图表中有几个数据系列,每个系列都有一个趋势线。我想传说只包括原始数据系列而不是趋势线。我想知道传说是否有我可以编辑的属性

1 个答案:

答案 0 :(得分:1)

Dim theChart As Worksheet
Dim oChart As ChartObject
Dim mySeries As Series
Dim objTrendline As Trendline

For Each oChart In theChart.ChartObjects
    For Each mySeries In oChart.Chart.SeriesCollection
        mySeries.Trendlines.Add
        objTrendline = mySeries.Trendlines(1)
        ' now just set the trendline legend label to blank
        objTrendline.Name = ""
    Next mySeries
Next oChart