Juggler_IN
Active Member
- Joined
- Nov 19, 2014
- Messages
- 358
- Office Version
- 2003 or older
- Platform
- Windows
I have a Chart with 10 Series. For one of the series (Series 9) I want to pass the values using an array.
I have created a SUB but I am unable to execute it, and can't figure out the reason.
There are two charts in the Sheet. Chart1 and Chart2. I want to pass values to Chart1.
Error that I am getting is, Method 'SeriesCollection' of 'Object '_Chart' failed.
I have created a SUB but I am unable to execute it, and can't figure out the reason.
There are two charts in the Sheet. Chart1 and Chart2. I want to pass values to Chart1.
Error that I am getting is, Method 'SeriesCollection' of 'Object '_Chart' failed.
Code:
Sub VBAchrt()
Dim myChart As Chart
Dim xlist As Variant, ylist As Variant, n As Long, i As Long
n = 1000
ReDim xlist(1 To n), ylist(1 To n)
For i = 1 To n
xlist(i) = Range("B" & i + 3).Value
ylist(i) = 1
Next i
Set myChart = ActiveSheet.ChartObjects(1).Chart
myChart.SeriesCollection(9).XValues = xlist
myChart.SeriesCollection(9).Values = ylist
End Sub