J
jonathan.underwood
Hi
I am trying to generate a chart from VBA arrays, but I am finding that
once the arrays become too large I get the following runtime error:
Run-time error '1004':
Unable to set the XValues property of the Series class
A simple piece of code which reproduces the error:
Option Base 1
Sub test()
Const nPts As Long = 81 'if increase this to >= 82, doesn't work!
Dim x(nPts) As Double, y(nPts) As Double
Dim i As Long
For i = 1 To nPts
x(i) = i
y(i) = i
Next i
'Create graph
Set Graph = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=375, Top:=75, Height:=225)
Graph.Activate
'Plot Data
With ActiveChart.SeriesCollection.NewSeries
.Name = "Data"
.XValues = x
.Values = y
.ChartType = xlXYScatter
End With
End Sub
This is with Excel 2003.
Any help with be fantastic!
Jonathan
I am trying to generate a chart from VBA arrays, but I am finding that
once the arrays become too large I get the following runtime error:
Run-time error '1004':
Unable to set the XValues property of the Series class
A simple piece of code which reproduces the error:
Option Base 1
Sub test()
Const nPts As Long = 81 'if increase this to >= 82, doesn't work!
Dim x(nPts) As Double, y(nPts) As Double
Dim i As Long
For i = 1 To nPts
x(i) = i
y(i) = i
Next i
'Create graph
Set Graph = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=375, Top:=75, Height:=225)
Graph.Activate
'Plot Data
With ActiveChart.SeriesCollection.NewSeries
.Name = "Data"
.XValues = x
.Values = y
.ChartType = xlXYScatter
End With
End Sub
This is with Excel 2003.
Any help with be fantastic!
Jonathan