spurs
Active Member
- Joined
- Oct 18, 2006
- Messages
- 479
- Office Version
- 2016
- 2013
- 2010
- 2007
- 2003 or older
- Platform
- Windows
I am trying to create a XY chart from values calculated in 2 arrays X & Y
See code below
Sub Createadeadchart()
Dim X(10), Y(10) As Variant
For i = 1 To 10
X(i) = 10 + i
Y(i) = 10 * i
Next i
Charts.Add
With ActiveChart
.SeriesCollection.NewSeries
.ChartType = xlXYScatterSmoothNoMarkers
.SeriesCollection(1).XValues = X
.SeriesCollection(1).Values = Y
.Deselect
End With
End Sub
When the chart is created, the XY point values are not as I intended them to be. ie for Data point I=1 i wanted the x,y value to be (11,10), but instead the first point plotted is Point 11 with a value of (2,10). The second point plotted is Point 12 value (3,20) etc.
What code do i have to use to end up with (11,10), (12,20), (13,30) etc. after plotting.
Thanks
See code below
Sub Createadeadchart()
Dim X(10), Y(10) As Variant
For i = 1 To 10
X(i) = 10 + i
Y(i) = 10 * i
Next i
Charts.Add
With ActiveChart
.SeriesCollection.NewSeries
.ChartType = xlXYScatterSmoothNoMarkers
.SeriesCollection(1).XValues = X
.SeriesCollection(1).Values = Y
.Deselect
End With
End Sub
When the chart is created, the XY point values are not as I intended them to be. ie for Data point I=1 i wanted the x,y value to be (11,10), but instead the first point plotted is Point 11 with a value of (2,10). The second point plotted is Point 12 value (3,20) etc.
What code do i have to use to end up with (11,10), (12,20), (13,30) etc. after plotting.
Thanks