finvba7
finvba7

Reputation: 1

"Next Without For" on a IF Statement in VBA

I am trying to verify that there are no error between the value in cells on column A and in Column C. I keep getting an error saying "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

Upvotes: 0

Views: 695

Answers (1)

psychicebola
psychicebola

Reputation: 949

you need to close the if statement before you can use the next keyword

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

Upvotes: 1

Related Questions