2016-03-27 124 views
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 

请告诉我该怎么做..提前

回答

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 

顺便说一句,如果你不嫌麻烦火起来的宏录制,插入一个新的图表工作表,定义新的系列,然后停止宏记录,你会看到全中规定的所有命令。