2016-03-27 154 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 

順便說一句,如果你不嫌麻煩火起來的宏錄製,插入一個新的圖表工作表,定義新的系列,然後停止宏記錄,你會看到全中規定的所有命令。