DavidSCowan
Board Regular
- Joined
- Jun 7, 2009
- Messages
- 78
I need to count backwards the runs of occurances of consectutive Ys (yes's) which are interupted by Ns.
So for example we have:
[TABLE="width: 603"]
<tbody>[TR]
[TD]Months:
[/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]6
[/TD]
[TD="align: right"]7
[/TD]
[TD="align: right"]8
[/TD]
[TD="align: right"]9
[/TD]
[TD="align: right"]10
[/TD]
[TD="align: right"]11
[/TD]
[TD="align: right"]12
[/TD]
[TD="align: right"]13
[/TD]
[TD="align: right"]14
[/TD]
[TD="align: right"]15
[/TD]
[TD="align: right"]16
[/TD]
[TD="align: right"]17
[/TD]
[TD="align: right"]18
[/TD]
[TD="align: right"]19
[/TD]
[TD="align: right"]20
[/TD]
[TD="align: right"]21
[/TD]
[TD="align: right"]22
[/TD]
[TD="align: right"]23
[/TD]
[TD="align: right"]24
[/TD]
[TD="align: right"]25
[/TD]
[/TR]
[TR]
[TD]Ys &Ns
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]N
[/TD]
[TD]Y
[/TD]
[TD]N
[/TD]
[TD]N
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]N
[/TD]
[TD]N
[/TD]
[TD]N
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[/TR]
[TR]
[TD]Backward runs of Ys
[/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]6
[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]6
[/TD]
[TD="align: right"]7
[/TD]
[TD="align: right"]8
[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[/TR]
</tbody>[/TABLE]
The end of a run of Ys comes when the next cell is an 'N'. e.g. the run of 4 Ys starting in month 25 comes to an end with the N in monthl 21.
Using Offset and Match I know how to do this going forwards but I can't do it going backwards!
Can anyone help please (I am using Excel 2007)
So for example we have:
[TABLE="width: 603"]
<tbody>[TR]
[TD]Months:
[/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]6
[/TD]
[TD="align: right"]7
[/TD]
[TD="align: right"]8
[/TD]
[TD="align: right"]9
[/TD]
[TD="align: right"]10
[/TD]
[TD="align: right"]11
[/TD]
[TD="align: right"]12
[/TD]
[TD="align: right"]13
[/TD]
[TD="align: right"]14
[/TD]
[TD="align: right"]15
[/TD]
[TD="align: right"]16
[/TD]
[TD="align: right"]17
[/TD]
[TD="align: right"]18
[/TD]
[TD="align: right"]19
[/TD]
[TD="align: right"]20
[/TD]
[TD="align: right"]21
[/TD]
[TD="align: right"]22
[/TD]
[TD="align: right"]23
[/TD]
[TD="align: right"]24
[/TD]
[TD="align: right"]25
[/TD]
[/TR]
[TR]
[TD]Ys &Ns
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]N
[/TD]
[TD]Y
[/TD]
[TD]N
[/TD]
[TD]N
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]N
[/TD]
[TD]N
[/TD]
[TD]N
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[/TR]
[TR]
[TD]Backward runs of Ys
[/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]6
[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]6
[/TD]
[TD="align: right"]7
[/TD]
[TD="align: right"]8
[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1
[/TD]
[TD="align: right"]2
[/TD]
[TD="align: right"]3
[/TD]
[TD="align: right"]4
[/TD]
[/TR]
</tbody>[/TABLE]
The end of a run of Ys comes when the next cell is an 'N'. e.g. the run of 4 Ys starting in month 25 comes to an end with the N in monthl 21.
Using Offset and Match I know how to do this going forwards but I can't do it going backwards!
Can anyone help please (I am using Excel 2007)