【发布时间】:2013-12-01 00:02:43
【问题描述】:
我正在处理这段代码,其中有两个嵌套循环,并且在指示的行中出现编译错误“Next without for”
Sub Isindenm()
Dim wb As Workbook
Dim ws As Worksheet
Dim B As Integer
Dim firstrow As Integer
Dim lLastRow As Long
lLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For firstrow = 14 To lLastRow
For B = 7 To 16
If IsNumeric(Cells(firstrow, B)) = True Then
Next B ***<-------------------Compile error:"next without for"***
Else
Cells(firstrow, 19) = Cells(firstrow, B)
End If
Next firstrow
End Sub
【问题讨论】:
-
你不能在 next 和 if then 这样的情况下交错。将您的 if 更改为
If Not IsNumeric(Cells(firstRow, "B")) Then