我有一个动态图表,可以更改在 excel 中绘制的系列数量,但是,我想要一种将图例中的系列名称更改为我在不同工作表的其他单元格中的名称的方法。我有以下代码,但我不确定如何更改图表系列行中的字母;
Dim i As Integer
Dim No_of_probes As Integer
Sheets("1. Paste Raw Data").Select
No_of_probes = Range("A2").Value
For i = 1 To No_of_probes
ActiveChart.FullSeriesCollection(i).Name = "='1. Paste Raw Data'!$C$4"
Next i
我希望它像这样循环,对于 For 循环的每次传递都以相同的方式递增,但我不确定如何在最后更改字母或单元格引用?我发现很难在任何地方找到与此类似的示例。
'ActiveChart.FullSeriesCollection(1).Name = "='1. Paste Raw Data'!$C$4"
'ActiveChart.FullSeriesCollection(2).Name = "='1. Paste Raw Data'!$D$4"
'ActiveChart.FullSeriesCollection(3).Name = "='1. Paste Raw Data'!$E$4"
'ActiveChart.FullSeriesCollection(4).Name = "='1. Paste Raw Data'!$F$4"
'ActiveChart.FullSeriesCollection(5).Name = "='1. Paste Raw Data'!$G$4"
'ActiveChart.FullSeriesCollection(6).Name = "='1. Paste Raw Data'!$H$4"
' ActiveChart.FullSeriesCollection(7).Name = "='1. Paste Raw Data'!$I$4"
'ActiveChart.FullSeriesCollection(8).Name = "='1. Paste Raw Data'!$J$4"
'ActiveChart.FullSeriesCollection(9).Name = "='1. Paste Raw Data'!$K$4"
'ActiveChart.FullSeriesCollection(10).Name = "='1. Paste Raw Data'!$L$4"
'ActiveChart.FullSeriesCollection(11).Name = "='1. Paste Raw Data'!$M$4"
'ActiveChart.FullSeriesCollection(12).Name = "='1. Paste Raw Data'!$N$4"
'ActiveChart.FullSeriesCollection(13).Name = "='1. Paste Raw Data'!$O$4"
最佳答案
这可以用来:
Dim i As Integer
Dim No_of_probes As Integer
Sheets("1. Paste Raw Data").Select
No_of_probes = Range("A2").Value
For i = 1 To No_of_probes
ActiveChart.FullSeriesCollection(i).Name = "='1. Paste Raw Data'!" & Range("C4").Offset(0, i - 1).Address
Next i
关于excel - 在动态 Excel 图中更改系列名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60060788/