0

我已经编写了使用两张表数据生成图表的代码。
代码是

 ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).XValues = "=SPEC!$B$2:$J$2"
ActiveChart.SeriesCollection(2).Values = "=SPEC!$B$6:$J$6"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Values = "=reference_curve!$D$4:$D$303"
ActiveChart.SeriesCollection(3).XValues = "=reference_curve!$C$4:$C$303"`

它工作正常,但问题是我想使用范围变量来选择数据。

dim test as range
test = "=SPEC!$B$6:$J$6"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).XValues = "=SPEC!$B$2:$J$2"
ActiveChart.SeriesCollection(2).Values = test
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Values = "=reference_curve!$D$4:$D$303"
ActiveChart.SeriesCollection(3).XValues = "=reference_curve!$C$4:$C$303"

这个不工作请帮帮我

4

1 回答 1

0

这是您设置变量以存储范围的方式:

dim test as range
Set test = Range("SPEC!$B$6:$J$6")
于 2012-09-20T10:11:29.330 回答