count consecutive cells matching string - start after 3 - ignore blanks between

godlev

New Member
Joined
Dec 1, 2016
Messages
11
i want find formula to count consecutive cells matching string (e.g. 1) but the counting of the consecutive cells to start after the 3rd consecutive entry
so if you have on a single row 5 consecutive times number 1 - the result should be 2 because the counting should start after 3rd entry
if you have 8 consecutive entries of number 1 but somewhere between them there is blank cell that should be also considered as single consecutive entry and the result should be 5


as shown on a row 9 - there are 9 consecutive times the number 1
the result is 6 because it should count only after the 3rd consecutive number 1

on row 10 is counting again only after the 3rd consecutive number 1
there are 2 consecutive entries with another number between them and it should be considered as two different consecutive entries of 1 - so the result should be 2

additionally on row number 11 are shown 2 consecutive entries with blank cell between them should be also considered as 1 consecutive entry

the numbers which the formula should count are shown below in red

[TABLE="class: grid, width: 290, align: center"]
<tbody>[TR]
[TD="align: center"]A1
[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[TD="align: center"]I[/TD]
[TD="align: center"]J[/TD]
[TD="align: center"]K[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="colspan: 9, align: center"]Entries
[/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD="align: center"]0[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1
[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1
[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD="align: center"]5[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1
[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD="align: center"]6[/TD]
[/TR]
[TR]
[TD="align: center"]10[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1
[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD="align: center"]5[/TD]
[/TR]
</tbody>[/TABLE]
 

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
Welcome to the forum.

How about:

K3: =SUM(IFERROR(SQRT(FREQUENCY(IF(B3:J3=1,COLUMN(B3:J3)),IF((B3:J3<>1)*(B3:J3<>""),COLUMN(B3:J3)))-3)^2,""))

confirmed with Control+Shift+Enter. The 1 in red (2 places) is the value you're looking for.
 
Upvote 0
thank you Eric
this solves my issue and it will save me alot of manual work and manual mistakes
 
Upvote 0
i just realized there is another requirement that i have to include
imagine there are 2 sheets sh1 and sh2
the counting should start from sh1 cells A1:A3
if there is 1 to continue the counting in sh2 where the whole data is as shown above
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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