我试图将数据点添加到Excel图表中,所以我基本上写道:
'Assume that ChartXY is a XYchart object created in an Excel sheet
Dim i as interger
Dim chartXY as Object
set chartXY = ActiveSheet.ChartObjects(1) 'There's one chart.
Dim PointsX(0 To 3, 0 To 0) As Double
Dim PointsY(0 To 3, 0 To 0) As Double
For i = 0 to 3
PointsX (i,0)= i
PointsY (i,0)= i
Next
With ChartXY.SeriesCollection
If .Count = 0 then .NewSeries
Item(1).Xvalues = PointsX
Item(1).Yvalues = PointsY
End If
With End
它似乎无法正常工作?任何想法!
答案 0 :(得分:0)
阐述Tim的评论:你对Item(1)的两个引用需要以一个点开头。
With ChartXY.Chart.SeriesCollection
If .Count = 0 then .NewSeries
.Item(1).Xvalues = PointsX
.Item(1).values = PointsY
End If
End With
答案 1 :(得分:0)
这是我的问题的答案:
Assume that ChartXY is a XYchart object created in an Excel sheet
Dim i as interger
Dim chartXY as Object
set chartXY = ActiveSheet.ChartObjects(1) 'There's one chart.
Dim PointsX(0 To 3, 0 To 0) As Double
Dim PointsY(0 To 3, 0 To 0) As Double
For i = 0 to 3
PointsX (i,0)= i
PointsY (i,0)= i
Next
With ChartXY.SeriesCollection
If .Count = 0 then .NewSeries
Item(1).values = PointsX
Item(1).Xvalues = PointsY
End If
With End