VBA中的IF声明中的“Next Without For”

时间:2015-08-12 09:35:03

标签: vba loops

我正在尝试验证列A和C列中单元格中的值之间没有错误。 我一直收到一条错误,上面写着“Next Without For”

Sub ISIN()

Dim i As Integer
Dim y As Integer
Dim t As Integer
Dim z As Integer
For i = 20 To 53
For y = 6 To 38
For t = 20 To 53
For z = 53 To 87
If Cells(i, 3) = Cells(y, 1) Then
Cells(t, 19) = "Abracadabra"
Else: Cells(z, 3) = Cells(y, 1)
Next z
Next t
Next y
Next i
End If
End Sub

1 个答案:

答案 0 :(得分:1)

您需要关闭if语句才能使用下一个关键字

Sub ISIN()

Dim i As Integer
Dim y As Integer
Dim t As Integer
Dim z As Integer
 For i = 20 To 53
  For y = 6 To 38
   For t = 20 To 53
    For z = 53 To 87
     If Cells(i, 3) = Cells(y, 1) Then
      Cells(t, 19) = "Abracadabra"
     Else
      Cells(z, 3) = Cells(y, 1)
     end if
   Next z
  Next t
 Next y
Next i
End Sub