Find Consecutive months without counting empty cell in the middle

tzianhao

New Member
Joined
Nov 15, 2018
Messages
2
ABCDEFGH
11803M1804M1805M1806M1807M1808M1809MRemarks
21111First Month
311112 Consecutive months
4111113 Consecutive months
511114 Consecutive months
61111115 Consecutive months

<tbody>
</tbody>

Is there a way to count a value consecutively with counting the empty cells in the middle ?
The return I want is like Column H where when there's an empty cell, it recounts from there.

I found that this formula works well but it counts everything.
=MAX(FREQUENCY(IF(A2:G2=1,COLUMN(A2:G2)),IF(A2:G2<>1,COLUMN(A2:G2))))
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi tzianhao,

One solution might be to find the last empty column using the following Array formula (column K):
=MAX(--((LEN($A2:$G2)=0)*COLUMN($A2:$G2)))
Enter it with Ctrl+Shift+Enter

Then, in column L, you can sum all values that are to the right of this one last empty column:
=SUM(INDEX($A2:$G2,1,$K2+1):INDEX($A2:$G2,1,7))

Combined Array formula (Ctrl+Shift+Enter):
=SUM(INDEX($A2:$G2,1,(MAX(--((LEN($A2:$G2)=0)*COLUMN($A2:$G2))))+1):INDEX($A2:$G2,1,7))

Does it help?
 
Upvote 0

Forum statistics

Threads
1,215,963
Messages
6,127,951
Members
449,412
Latest member
montand

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