#### Topic: The strange error

The program worked normally, but now produces error Compile Error Next without For in line

``Next i``

.

``````Function &#243;&#241;&#235;&#238;&#226;&#232;&#229;4&#225; (Diapozon As Range) As Long
' &#228;&#235;&#255; &#241;&#232;&#242;&#243;&#224;&#246;&#232;&#232;
Application. Volatile
Dim k As Long, n As Long, i As Long, m As Long
Dim C As Range
k =-2
n = 0
m = 0
For i = Diapozon. Rows. Count To 1 Step-1
Set A C = Diapozon. Rows (I)
If (C.Offset (0,-3).Value &lt;&gt; &#203;&#206;&#198;&#220; Or C.Offset (0,-4).Value = &#203;&#206;&#198;&#220; Or C.Offset (0,-6).Value &lt;&gt; &#203;&#206;&#198;&#220; Or C.Offset (0,-7).Value &lt;&gt; &#203;&#206;&#198;&#220; Or C.Value = 0) And k =-2 Then
n = 0
Exit For
End If
If k =-2 Then
k = 0
GoTo Label1
End If
If C.Offset (0,-6).Value &lt;&gt; &#203;&#206;&#198;&#220; Then
GoTo Label1
End If
If C.Offset (0,-7).Value &lt;&gt; &#203;&#206;&#198;&#220; Then
GoTo Label1
End If
If C.Offset (0,-5).Value = 0 Then
GoTo Label1
End If
If C.Value = 0 Then
GoTo Label1
End If
If C.Offset (0,-5).Value = 1 Then
If C.Value = 2 Then
n = 1
Exit For
Else
n = 0
Exit For
End If
Label1:
Next i
&#243;&#241;&#235;&#238;&#226;&#232;&#229;4&#225; = n
End Function``````

#### Re: The strange error

Balance If and End If does not converge.

#### Re: The strange error

Horror what.
Here Goto  it is not necessary - look at the operator ElseIf
And conditions can be united in single line through And, instead of to write for each step separate If

Akina;

#### Re: The strange error

Shocker. Pro;
Yes at me on Goto all programs are based)

#### Re: The strange error

https://yandex.ru/search/? text=goto &clid=2207714&lr=213

#### Re: The strange error

Shocker. Pro;
And as

``on error goto errH``

#### Re: The strange error

big-duke wrote:

and as

It only on letters GoTo...