How to change series name in VBA

前端 未结 2 1920
滥情空心
滥情空心 2020-12-19 11:04

I have a series of charts I am creating using VBA (code below).

I am having trouble changing the names of the series from series 1 and series 2 to Current State and

2条回答
  •  执念已碎
    2020-12-19 11:38

    Try changing these lines ...

         Set Srs1 = ActiveChart.SeriesCollection(1) 
         Srs1.Name = "Current State"
         Set Srs2 = ActiveChart.SeriesCollection(2) 
         Srs2.Name = "Proposed Solution"
    

    To ...

         .SeriesCollection(1).Name = "Current State"
         .SeriesCollection(2).Name = "Proposed Solution"
    

    You are already using MAChart inside your With block so you should be able to access it's .SeriesCollection(x).Name properties in the same fashion as you have done for the other properties.

提交回复
热议问题