我正在尝试将包含多个工作表中的数据的图表绘制到同一个图表中。所以每张纸的数据在我的图表中都是一个单独的系列。这是 2 张纸的示例代码:
Name1 = ActiveWorkbook.Worksheets(1).Name
Name2 = ActiveWorkbook.Worksheets(2).Name
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SetSourceData Source:=Range("'" & Name1 & "'!$C$" & nStart & ":$D$" & nLast & "")
ActiveChart.SeriesCollection(1).Name = "=" & Name1 & "!A1"
ActiveChart.SeriesCollection(1).XValues = "='" & Name1 & "'!$C$" & nStart & ":$C$" & nLast & ""
ActiveChart.SeriesCollection(1).Values = "='" & Name1 & "'!$E$" & nStart & ":$E$" & nLast & ""
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SetSourceData Source:=Range("'" & Name2 & "'!$C$" & nStart & ":$D$" & nLast & "")
ActiveChart.SeriesCollection(2).XValues = "='" & Name2 & "'!$C$" & nStart & ":$C$" & nLast & ""
ActiveChart.SeriesCollection(2).Values = "='" & Name2 & "'!$E$" & nStart & ":$E$" & nLast & ""
ActiveChart.SeriesCollection(2).Name = "=" & Name2 & "!A1"
但我在第二系列集合中收到“无效参数”错误。请帮我解决这个问题。
谢谢!