Find Consecutive months without counting empty cell in the middle

tzianhao

New Member
Joined
Nov 15, 2018
Messages
2
[TABLE="width: 800"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1803M[/TD]
[TD]1804M[/TD]
[TD]1805M[/TD]
[TD]1806M[/TD]
[TD]1807M[/TD]
[TD]1808M[/TD]
[TD]1809M[/TD]
[TD]Remarks[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]First Month[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2 Consecutive months
[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]3 Consecutive months [/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]4 Consecutive months[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]5 Consecutive months [/TD]
[/TR]
</tbody>[/TABLE]

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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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