我正在尝试添加一个新的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 :(得分: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
顺便说一句,如果您不小心启动宏录制器,插入新的图表,定义新系列,然后停止宏录制器,您将看到完整的所有命令。