[英]Next without For Error - What is wrong with this code?
I assume there is something wrong with my code below, because it is giving me the following error: Compile error: Next without For
我认为下面的代码有问题,因为它给了我以下错误:
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
You are missing an End With
: 您缺少
End With
:
With s
.Values = yaxis
.XValues = xaxis
End With ' <====== HERE
Next i
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.