W
Wm
I am trying to chart an array of data but I get an error (sometimes). Here
is an example macro that exhibits the behavior:
Sub Macro1()
Dim i As Integer, n As Integer
Dim xArray() As Variant
Dim yArray() As Variant
n = 14
ReDim xArray(1 To n)
ReDim yArray(1 To n)
For i = 1 To n
xArray(i) = i
yArray(i) = Rnd()
Next i
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = xArray
ActiveChart.SeriesCollection(1).Values = yArray
End Sub
The macro works fine by setting n to any value up to 13 but errors at the
last statement with larger values for n. Can anyone fix this macro so it
works?
TIA,
William Schmidt
is an example macro that exhibits the behavior:
Sub Macro1()
Dim i As Integer, n As Integer
Dim xArray() As Variant
Dim yArray() As Variant
n = 14
ReDim xArray(1 To n)
ReDim yArray(1 To n)
For i = 1 To n
xArray(i) = i
yArray(i) = Rnd()
Next i
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = xArray
ActiveChart.SeriesCollection(1).Values = yArray
End Sub
The macro works fine by setting n to any value up to 13 but errors at the
last statement with larger values for n. Can anyone fix this macro so it
works?
TIA,
William Schmidt