montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- Windows
Hi everyone.
this code
is doing good to certain point.
because is counting the "Rows" where the target value " 1 " is not present
but, when arrived to the last location of number one then do not count anymore
so what I want is to count
also after the last one to the end of the array
I am loading a picture that maybe show you better the idea
as you see is perfect the count of 3,9 "0's if repeating" and 1
and the code stop right there,
I really need the last part count also, meaning in this case
must be 6 rows where number one is not present also.
Please any help.
Thank you for reading this.
this code
VBA Code:
Sub jump()
Dim i As Long, n As Long
Dim f As Range
For i = 2 To Range("B" & Rows.Count).End(3).Row
'target value ( 1 )
Set f = Range("B" & i).Resize(, 5).Find(1, , xlValues, xlWhole)
If Not f Is Nothing Then
Range("K" & Rows.Count).End(xlUp).Offset(1, 0).Value = n
n = -1
End If
n = n + 1
Next
End Sub
because is counting the "Rows" where the target value " 1 " is not present
but, when arrived to the last location of number one then do not count anymore
so what I want is to count
also after the last one to the end of the array
I am loading a picture that maybe show you better the idea
as you see is perfect the count of 3,9 "0's if repeating" and 1
and the code stop right there,
I really need the last part count also, meaning in this case
must be 6 rows where number one is not present also.
Please any help.
Thank you for reading this.