我目前正在使用这个宏来生成我从另一张纸中获取价值的图表。当未检测到 sheet1 在 A 列中没有任何输入时,如何通过停止添加系列来简化这一点。
ActiveSheet.ChartObjects("CH 1").Activate
ActiveChart.SeriesCollection.NewSeries.MarkerStyle = False
ActiveChart.SeriesCollection(1).Name = "='Sheet1'!$A$2"
ActiveChart.SeriesCollection(1).Values = "='data'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Name = "='Sheet1'!$A$3"
ActiveChart.SeriesCollection(2).Values = "='data (2)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Name = "='Sheet1'!$A$4"
ActiveChart.SeriesCollection(3).Values = "='data (3)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(4).Name = "='Sheet1'!$A$5"
ActiveChart.SeriesCollection(4).Values = "='data (4)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(5).Name = "='Sheet1'!$A$6"
ActiveChart.SeriesCollection(5).Values = "='data (5)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(6).Name = "='Sheet1'!$A$7"
ActiveChart.SeriesCollection(6).Values = "='data (6)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(7).Name = "='Sheet1'!$A$8"
ActiveChart.SeriesCollection(7).Values = "='data (7)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(8).Name = "='Sheet1'!$A$9"
ActiveChart.SeriesCollection(8).Values = "='data (8)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(9).Name = "='Sheet1'!$A$10"
ActiveChart.SeriesCollection(9).Values = "='data (9)'!$B$2:$B$400"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(10).Name = "='Sheet1'!$A$11"
ActiveChart.SeriesCollection(10).Values = "='data (10)'!$B$2:$B$400"