The problem I have is already stated in the title - I have a loop generating 18 series in my code and I'd like all of those 18 series to be plotted on one graph. Somehow I don't know how to do it. It's probably a simple and obvious mistake, but I fail to see it. Hopefully someone could point it out.
The relevant part of my code:
This code only plots the first (i=1) series and the graph's data set has only the 1st series in its data set. If I, however, delete the Exit For's then only the last (i=137) series is plotted and all the others are in the graph's data set but are empty.
Would appreciate any help!
The relevant part of my code:
Code:
'add a chart
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
'avoid extra series
Do Until ActiveChart.SeriesCollection.Count = 0
ActiveChart.SeriesCollection(1).Delete
Loop
'loop through columns
For i = 1 To 137 Step 8
j = Cells(30, i).End(xlDown).Row
If Abs(Cells(30, i)) = 0.2 Or Abs(Cells(30, i)) = 0.3 Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).Name = Cells(12, i + 5)
ActiveChart.FullSeriesCollection(1).XValues = Range(Cells(31, i), Cells(j, i))
ActiveChart.FullSeriesCollection(1).Values = Range(Cells(31, i + 1), Cells(j, i + 1))
Exit For
Else
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).Name = Cells(12, i + 5)
ActiveChart.FullSeriesCollection(1).XValues = Range(Cells(30, i), Cells(j, i))
ActiveChart.FullSeriesCollection(1).Values = Range(Cells(30, i + 1), Cells(j, i + 1))
Exit For
End If
Next
Would appreciate any help!