count number of times a value appears in a column

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,126
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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi,

Perhaps try:

Sheet1
[TABLE="class: html-maker-worksheet"]
<tbody>[TR]
[TH][/TH]
[TH]A[/TH]
[TH]B[/TH]
[TH]C[/TH]
[TH]D[/TH]
[/TR]
[TR]
[TH]1[/TH]
[TD]List[/TD]
[TD][/TD]
[TD]Value[/TD]
[TD]Max consecutive count[/TD]
[/TR]
[TR]
[TH]2[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD]no[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TH]3[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]4[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]5[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]6[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]7[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]8[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]9[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]10[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]11[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]12[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]13[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]14[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]15[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]16[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]17[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]18[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]19[/TH]
[TD]no[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]20[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TH]21[/TH]
[TD]yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Excel 2010
CellFormula
D2=MAX(FREQUENCY(
IF(A2:A21=C2,ROW(A2:A21)),
IF(A2:A21<>C2,ROW(A2:A21))
)
)

<tbody>
[TD="bgcolor: #FFFFFF"] Array Formulas [TABLE="class: html-maker-worksheet"]
<tbody>[TR]

</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}. Note: Do not try and enter these manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
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

[TABLE="width: 144"]
<TBODY>[TR]
[TD="class: xl64, width: 64, bgcolor: transparent"]Data
[/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 64, bgcolor: transparent"]Count
[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]yes
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2
[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]yes
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl64, bgcolor: transparent"]List
[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]no
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]4
[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]no
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2
[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]no
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]no
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]yes
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]no
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"]no
[/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
</TBODY>[/TABLE]

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,223,575
Messages
6,173,148
Members
452,503
Latest member
AM74

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