Checking for consecutive numbers

sonyaltec

New Member
Joined
Feb 10, 2023
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Please help. Looking for a formula dynamic enough to use through out the entire year to detect consecutive non zero months. However, every consecutive 3 months block will form a cut off resetting the count to 0 again (Scenario A). The formula needs to follow the moving date. Expanding on that a second formula with the same logic but detecting every consecutive month with values greater than or equal to 3 (Scenario B). Illustrated below:

Book1.xlsx
ABCDEFGHIJKLMN
113/3/2023
2
3JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberConsecutive Months Indicator
4Scenario 1 (a)122
5Scenario 1 (b)21511
6Scenario 1 (c)106170
7Scenario 2 (a)3031
8Scenario 2 (b)36373931
9Scenario 2 (c)3312337810
Sheet1
Cell Formulas
RangeFormula
A1A1=TODAY()-1
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi,
You can test following formula for cell B5
Excel Formula:
=AND(B5<>0,C5<>0,D5<>0,MOD(COLUMN()-1,3)=1)
 
Upvote 0
Book1
ABCDEFGHIJKLMN
3JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberConsecutive Months Indicator
4Scenario 1 (a)122
5Scenario 1 (b)21511
6Scenario 1 (c)106170
7Scenario 2 (a)3031
8Scenario 2 (b)36373931
9Scenario 2 (c)3312337810
Sheet1
Cell Formulas
RangeFormula
N4:N9N4=MOD(LOOKUP(2,1/(B4:M4>0)/(B4:M4<>""),COLUMN(B4:M4))-IFERROR(LOOKUP(2,1/(B4:M4=0)/(B4:M4<>""),COLUMN(B4:M4)),1),3)
 
Upvote 0
Hi again,
For the Conditional Formatting rule, starting in cell B5, you can test:
Excel Formula:
=AND(OFFSET($B5,0,INT(INT(COLUMN()-2)/3)*3)<>0,OFFSET($C5,0,INT(INT(COLUMN()-2)/3)*3)<>0,OFFSET($D5,0,0)<>INT(INT(COLUMN()-2)/3)*3)
and apply it right and down to all scenarios.
 
Upvote 0
Book1
ABCDEFGHIJKLMN
3JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberConsecutive Months Indicator
4Scenario 1 (a)122
5Scenario 1 (b)21511
6Scenario 1 (c)106170
7Scenario 2 (a)3031
8Scenario 2 (b)36373931
9Scenario 2 (c)3312337810
Sheet1
Cell Formulas
RangeFormula
N4:N9N4=MOD(LOOKUP(2,1/(B4:M4>0)/(B4:M4<>""),COLUMN(B4:M4))-IFERROR(LOOKUP(2,1/(B4:M4=0)/(B4:M4<>""),COLUMN(B4:M4)),1),3)

hi bebo021999, theres an error where the calculation doesnt work if the latest month is 0.

Consecutive Month Formula.xlsx
ABCDEFGHIJKLMN
113/3/20239
2
3123456789101112Consecutive Months Indicator
4Scenario 1 (a)1231010102
Sheet1
Cell Formulas
RangeFormula
A1A1=TODAY()-1
N4N4=MOD(LOOKUP(2,1/(B4:M4>0)/(B4:M4<>""),COLUMN(B4:M4))-IFERROR(LOOKUP(2,1/(B4:M4=0)/(B4:M4<>""),COLUMN(B4:M4)),1),3)


also i made an error in the assumption previously. it should disregard the current month (latest month) number when counting consecutive month. Meaning if we are in the month of May, (feb 0,march 2, april 2) consecutive month shown will be 2 regardless of what number is in May.
 
Upvote 0
Hi,
Did you test the formula in post # 4 ...

Sorry could you guide me through how to achieve that? Tried this but did not see any results.

1678840935938.png
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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