In the column “V34:V99” there are digits 1,2,3,0 in the scattered order .
I want to count how many situations will be (n) (three consecutive 1 к=3
, without taking into account zeroes) ,if 2 or 3 occur , then k=o
.
I wrote the code but it doesn’t work (doesn’t give a number of situations (n)).
0
1
0
1
0
0
0
1
0
1
0
0
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
0
1
0
0
0
0
3
0
1
0
3
0
0
0
3
0
1
0
1
0
0
1
3
0
1
0
0
0
0
0
0
0
0
0
0
0
0
Code
Sub а33условие3()
Dim k, n As Integer
Dim parRange As Range
Set parRange = Range("V34:V99")
k = 0
n = 0
For Each Cell In parRange.Rows
If Cell.Value = 1 Then
k = k + 1
If k = 3 Then
n = n + 1
k = o
MsgBox n
End If
End If
If Cell.Value = 2 Or 3 Then
k = 0
End If
Next Cell
End Sub