count number of times a value appears in a column

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,104
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Dear all

Is there a way of counting how many times something appears in a column before the value changes.
below NO appears 10 times in a row, this being the max number of times in a row.

yes
yes
yes
yes
no
no
no
yes
no
no
no
no
no
no
no
no
no
no
yes
yes

Thanks

Dave
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

Perhaps try:

Sheet1
ABCD
1ListValueMax consecutive count
2yesno10
3yes
4yes
5yes
6no
7no
8no
9yes
10no
11no
12no
13no
14no
15no
16no
17no
18no
19no
20yes
21yes

<tbody>
</tbody>
Excel 2010
Array Formulas
CellFormula
D2=MAX(FREQUENCY(
IF(A2:A21=C2,ROW(A2:A21)),
IF(A2:A21<>C2,ROW(A2:A21))
)
)

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}. Note: Do not try and enter these manually yourself

<tbody>
</tbody>
Note:
 
Last edited:
Upvote 0
Dear all

Is there a way of counting how many times something appears in a column before the value changes.
below NO appears 10 times in a row, this being the max number of times in a row.

yes
yes
yes
yes
no
no
no
yes
no
no
no
no
no
no
no
no
no
no
yes
yes

Thanks

Dave

Control+shift+enter, not just enter:

=MAX(FREQUENCY(IF(A2:A23="no",ROW(A2:A23)),IF(A2:A23="yes",ROW(A2:A23))))
 
Upvote 0
thanks guys

that worked great, just one more thing, can you count how many times the number of times a maximum is reached and can i use the same formula but use the large function for finding secon highest etc.

i guess i will just try that one.

thanks again

Dave
 
Upvote 0
thanks guys

that worked great, just one more thing, can you count how many times the number of times a maximum is reached and can i use the same formula but use the large function for finding secon highest etc.

i guess i will just try that one.

thanks again

Dave

Data
Count
yes
2
yes
List
no
4
no
2
no
no
yes
no
no

<TBODY>
</TBODY>

C2, control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(A2:A23="no",ROW(A2:A23)),
  IF(A2:A23="yes",ROW(A2:A23)))>1,1))
C4, control+shift+enter and copy down:
Rich (BB code):
=IF(ROWS($C$4:C4)<=$C$2,LARGE(FREQUENCY(IF($A$2:$A$23="no",
  ROW($A$2:$A$23)),IF($A$2:$A$23="yes",ROW($A$2:$A$23))),ROWS($C$4:C4)),"")
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,227
Members
448,878
Latest member
Da9l87

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