0

我正在尝试添加一个新的 chart1 表并将 sheet1 中的系列添加到我的 chart1 表中。

这是我的代码...

Charts.Add
With ActiveChart
    .ChartType = xlLine
    .HasTitle = True
    .ChartTitle.Text = "Closing Price"
    .SeriesCollection.NewSeries
    .FullSeriesCollection.XValues = "=Sheet1!$A$2:$A$741" '<<<<This is the xvalue
    .FullSeriesCollection.Values = "=Sheet1!$B$2:$B$741"  '<<<<This are the value 
End With

请告诉我如何做到这一点.. 提前致谢

4

1 回答 1

0

您必须指定系列集合的数量。

Charts.Add
With ActiveChart
    .ChartType = xlLine
    .HasTitle = True
    .ChartTitle.Text = "Closing Price"
    .SeriesCollection.NewSeries
    .FullSeriesCollection(1).XValues = "=Sheet1!$A$2:$A$741" '<<<<This is the xvalue
    .FullSeriesCollection(1).Values = "=Sheet1!$B$2:$B$741"  '<<<<This are the value
End With

顺便说一句,如果你不厌其烦地启动宏记录器,插入新图表,定义新系列,然后停止宏记录器,你会看到所有命令的完整布局。

于 2016-03-27T21:36:44.347 回答