Reputation: 1822
I assume there is something wrong with my code below, because it is giving me the following error: Compile error: Next without For
What is wrong with my code? Thanks! :)
Sub CreateCharts()
Dim i As Integer
For i = 3 To 5
col = Columns(i).Select
Dim xaxis As Range
Dim yaxis As Range
Set yaxis = Range("$" & col & "$152", "$" & col & "$156")
Set xaxis = Range("$A$152", "$A$156")
Dim c As Chart
Set c = ActiveWorkbook.Charts.Add
Set c = c.Location(Where:=xlLocationAsObject, Name:="Sheet1")
c.ChartType = xlColumnClustered
Dim s As Series
Set s = c.SeriesCollection.NewSeries
With s
.Values = yaxis
.XValues = xaxis
Next i
End Sub
Upvotes: 0
Views: 58
Reputation: 328608
You are missing an End With
:
With s
.Values = yaxis
.XValues = xaxis
End With ' <====== HERE
Next i
Upvotes: 5