Counting how many times a word is shown one after the other

seriousdamage

Board Regular
Joined
Aug 14, 2005
Messages
58
I have a file with one column and 2000 rows
In each sell there can be the word day or night
I would like to count how many times the word day shows after each other

As an example, if from A1 to A6 I always have Day, but in A7 I have night, the count is 6
If in A8 we find the word Day again, then the count starts again.

Many Thanks for any help
Regards
Nic
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Not sure if this is what you want, but it does the count...
A​
B​
2​
aa day
1​
3​
bb day
2​
4​
cc day
3​
5​
dd day
4​
6​
aa night
0​
7​
ee day
1​
8​
ff day
2​
9​
gg day
3​
10​
bb night
0​
11​
cc night
0​
12​
hh day
1​
B2=IF(ISNUMBER(SEARCH("day",A2)),B1+1,0)
copied down
 
Upvote 0
Are you looking for the longest consecutive run of the word "day" in a column? If so, try:

Excel 2012
ABC
1day8
2day
3day
4day
5day
6day
7night
8day
9day
10night
11day
12day
13day
14day
15day
16day
17day
18day
19night
20night
21night
22night
23day
24day
25night

<colgroup><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
C1{=MAX(FREQUENCY(IF(A1:A25="day",ROW(A1:A25)),IF(A1:A25<>"day",ROW(A1:A25))))}

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

<tbody>
</tbody>
 
Upvote 0
I took the question to mean that "day" would be somewhere inside a string in a cell, but Eric showed a different (and possibly correct) view. In this case, my suggestion is modified to...
D​
E​
2​
day
1​
3​
day
2​
4​
day
3​
5​
day
4​
6​
day
5​
7​
day
6​
8​
night
0​
9​
day
1​
10​
day
2​
11​
night
0​
12​
day
1​
13​
day
2​
14​
day
3​
15​
day
4​
16​
day
5​
E2=IF(D2="day",E1+1,0)
copied down
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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