代码改变世界

vba 更新折线图上显示内容

2016-07-01 10:34  sylar_liang  阅读(634)  评论(0编辑  收藏  举报

Dim nCount As integer

nCount = ActiveSheet.ChartObjects.count //当前工作表有多少个图表

//更新规格线显示的内容

Dim chartName As string

chartName = "规格: " & Cells(iRow, "E").Value & "以上"

ActiveSheet.ChartObjects("图表1").Activate

ActiveChart.SeriesCollection(3).Name = chartName

//显示为红色 

ActiveChart.Legend.LegendEntries(3).Select

With Selection.Format.TextFrame2.TextRange.Select

  .Fill.ForeColor.RGB = RGB(255, 0, 0)

End With