Count consecutive number with largest value and sum this

meohen1992

New Member
Joined
Jul 30, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,
I am trying to find consecutive numbers with largest value.
I have used the formula then did not worked exactly like I want:
=MAX(FREQUENCY(IF(A2:A26>0,ROW(A2:A26)),IF(A2:A26<=0,ROW(A2:A26))))

This formula return longest sequence of numbers, not consecutive numbers with largest value...
The result I want is : 6 and 3839

Thanks,
Huy
Book1
ABCDEF
1ValueConsecutive positiveSum thisConsecutive with largest numberSum this
2623111,78563,839
3212Result Formula I want
4109
5291
6280
72,325
8-1,575
9632
101,287
11-1,175
12368
13-285
14-497
15-9
16429
17173
1890
1918
2057
2110
2263
23444
24410
2569
2622
Sheet1
Cell Formulas
RangeFormula
B2B2=MAX(FREQUENCY(IF(A2:A26>0,ROW(A2:A26)),IF(A2:A26<=0,ROW(A2:A26))))
C2C2=MAX((COUNTIF(OFFSET(A2:A26,ROW(A2:A26)-ROW(A2),0,B2),">=0")=B2)*SUBTOTAL(109,OFFSET(A2:A26,ROW(A2:A26)-ROW(A2),0,B2)))
E2E2=COUNT(A2:A7)
F2F2=SUM(A2:A7)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F2Cell Value>0textNO
F2Cell Value<0textNO
C2Cell Value>0textNO
C2Cell Value<0textNO
A2:A26Cell Value>0textNO
A2:A26Cell Value<0textNO
 
Did you try the formula I suggested? It's non-volatile & therefore won't calculate as often.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Did you try the formula I suggested? It's non-volatile & therefore won't calculate as often.
Hi sir.
Thanks for your idea. it works and runs correctly.
However I cannot filter when use it, like Anonymous1378's formula.
 
Upvote 0
If you want all the groups listed (I removed the requirement for the empty row):

Book1
ABCDEFG
1ValueConsecutive positiveSum thisStarting rowGroup sizeSum
2622.51111785.18263839.36
3211.5921918.56
4109.316111785.18
5291.31121368.26
6280133-790.69
72324.74111-1175
8-157581-1575
9631.5
101287.06
11-1175
12368.26
13-285
14-496.69
15-9
16428.98
17173.09
1890.02
1918
2056.63
2110.39
2263.26
23444.14
24410.3
2568.68
2621.69
Sheet4
Cell Formulas
RangeFormula
E2:G8E2=LET(a,IF(IFERROR(SIGN(A1:A26),0)<>SIGN(A2:A27),ROW(A2:A27)),c,COUNT(a)-1,s,SEQUENCE(c),sa,SMALL(a,s),sb,SMALL(a,s+1),d,SUBTOTAL(9,OFFSET(A1,sa-1,0,sb-sa)),SORT(CHOOSE({1,2,3},sa,sb-sa,d),3,-1))
Dynamic array formulas.
 
Upvote 0
If you want all the groups listed (I removed the requirement for the empty row):

Book1
ABCDEFG
1ValueConsecutive positiveSum thisStarting rowGroup sizeSum
2622.51111785.18263839.36
3211.5921918.56
4109.316111785.18
5291.31121368.26
6280133-790.69
72324.74111-1175
8-157581-1575
9631.5
101287.06
11-1175
12368.26
13-285
14-496.69
15-9
16428.98
17173.09
1890.02
1918
2056.63
2110.39
2263.26
23444.14
24410.3
2568.68
2621.69
Sheet4
Cell Formulas
RangeFormula
E2:G8E2=LET(a,IF(IFERROR(SIGN(A1:A26),0)<>SIGN(A2:A27),ROW(A2:A27)),c,COUNT(a)-1,s,SEQUENCE(c),sa,SMALL(a,s),sb,SMALL(a,s+1),d,SUBTOTAL(9,OFFSET(A1,sa-1,0,sb-sa)),SORT(CHOOSE({1,2,3},sa,sb-sa,d),3,-1))
Dynamic array formulas.
Thank you for re-editing and adding find out the location of results.
I will use this function to further analyze the given data. 🤝
 
Upvote 0
I think I have found the answer.
Thank you so much everyone for helping me. 🙇
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,189
Members
449,090
Latest member
bes000

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