Count of last consecutive repetitive values in a column

JONVEN

New Member
Joined
Sep 21, 2022
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hello Excel Masters,

I have a problem which I am stuck with.. I have checked the forum and could not find the answer, even though I am quite close with to get the answer with this formula (Count number of times a value appears in role??) I am still looking for suggestion.

So, let's say a have a column with values:
Y
N
Y
Y
Y
N
N
N

I need a formula which would count number of last (not MAX) Ns in a row,- in this case this would be 3

In case of:
Y
Y
Y
N
N
Y

The formula should return 0, because last value is not N

Also would be great if formula could still count a number of last Ns in a row if there's 0s or blanks after Ns. In case of:
Y
N
N
Y
N
N
N
0/Blank
0/Blank

The formula should return 3, because before 0s/Blanks there was 3 consecutive Ns.

Hope the question is clear and someone could help me.
Thanks in advance.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
How about
Fluff.xlsm
AB
1Yes/No
2y3
3n
4y
5n
6n
7n
8
9
10
Daily
Cell Formulas
RangeFormula
B2B2=COUNTA(A:A)-LOOKUP(2,1/(($A$2:$A$100<>"N")*($A$2:$A$100<>"")),ROW($A$2:$A$100))
 
Upvote 0
Cannot get exactly the results I am looking for, let's say I have:
row no.B
1Y
2N
3Y
4N
5N
6N
70
80
90

I would like to get 3 as an answer (with your formula I get 0), because before 0s there are 3 Ns.
0's are here because this data will be updated once it is available and it will become either Y or N
Also I am not quite sure I understand the range, in my case the range is fixed, in this case B2:B9
 
Upvote 0
I am not quite sure I understand the range, in my case the range is fixed, in this case B2:B9
You never said that, so how was I to know. ;)
Can you ever have blank cells at the end of the data rather than zeros?
 
Upvote 0
Yes, I believe I can sort something out and have blanks instead of zeros, thanks.
 
Upvote 0
If it will always be zeros & not blanks then you can use
Excel Formula:
=COUNTIFS(B1:B9,"<>0")-LOOKUP(2,1/((B2:B9<>"N")*(B2:B9<>0)),ROW(B2:B9))
 
Upvote 0
Let's say a have data:
row no.B
1​
Y
2​
N
3​
Y
4​
N
5​
N
6​
N
7​
0​
8​
0​
9​
0​
10​
Y
11​
Y
12​
Y
13​
N
14​
N
15​
N
16​
N
17​
0​
18​
0​
19​
0​
20​
0​

I use formula =COUNTIFS(B2:B21,"<>0")-LOOKUP(2,1/((B3:B21<>"N")*(B3:B21<>0)),ROW(B3:B21)) and get the result of 0, even though I expect to get 4
 
Upvote 0
Will you please provide some data showing EXACTLY what you have.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

It is impossible to write a formula that works when you keep moving the goal posts.
 
Upvote 0
Maybe I could send you my sheet and all the details what I want to do through e-mail, because my sheet is quite wide, not sure whether it is ok to post such a big table.
 
Upvote 0
Maybe I could send you my sheet and all the details what I want to do through e-mail,
Fraid not, that is against the board rules. Everything must remain in the thread for all to see.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top