montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 986
- Office Version
- 2010
- Platform
- Windows
Hi, everyone
I'm trying to count ranges between the same value
Here's what I have so far:
I'm having trouble getting it to work properly.
My array example for short is:
I am trying to be simple!.
so the code return this
so until here is right, meaning, count only one cell in the column be, and this cell it is not equal to 6, then skip 2 not equal to 6 then etc.
so, what is my question here
If I have the target value in different cell in the range then this code do not count, let me show you
now like this, I try like
Set rngData = Range("B2:F11")
do not work, also like
Set rngData = Range("B2:F2 , B11:F11")
do not work
So please, anyway you can help me here.
I'm trying to count ranges between the same value
Here's what I have so far:
VBA Code:
Sub jumping()
Set rngData = Range("B2:B11")
n = 0
m = 1
For Each cell In rngData
If cell = 6 Then
Range("H2").Offset(0, m) = n
n = 0
m = m + 1
Else
n = n + 1
End If
Next
End Sub
I'm having trouble getting it to work properly.
My array example for short is:
I am trying to be simple!.
so the code return this
so until here is right, meaning, count only one cell in the column be, and this cell it is not equal to 6, then skip 2 not equal to 6 then etc.
so, what is my question here
If I have the target value in different cell in the range then this code do not count, let me show you
now like this, I try like
Set rngData = Range("B2:F11")
do not work, also like
Set rngData = Range("B2:F2 , B11:F11")
do not work
So please, anyway you can help me here.