finding block having the maximum sum for a range of cells

ABHISKV4

New Member
Joined
May 26, 2009
Messages
31
Office Version
  1. 365
Platform
  1. Windows
I want two formulas for a particular scenario:

Query 1. the block of 4 consecutive cells which has the maximum sum(blocks to be considered from the left most cell and then the blocks run from left to right)
Query 2. the starting cell number of the block having the maximum sum.

If there are two blocks having the same sum, then the first block can be used as the result. In the below image, the first block (Block1) contains 18,50,37 and 44 while the last block (Block15) contains 72,84,88,30

1599035867554.png
 

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.
Abhiskv4,
Is this calculation to be mixed with the other one you asked for earlier today?
Anyway, you should really plan how your sales or stats table should develop and look like over a whole reporting period.
My thesis is that no formula monster will make you happy at the end of the year.
 
Upvote 0
Anyway, you should really plan how your sales or stats table should develop and look like over a whole reporting period.
My thesis is that no formula monster will make you happy at the end of the year.
I really wish I could do that, however in reality, the data can extend to multiple years as well, depends on case to case basis. There is nothing like a pre-defined limit on the no. of columns in the so called stats table. However, I am happy to state that the formula's suggested by all the esteemed members on this community are very well serving my purpose :)
 
Upvote 0
So now I am tweaking the requirement to a more useful yet practical scenario.
Assume that i have 156 cells in a row running from cell C3 to FB3. Now I want the "block size" to be user input (call it 1) and the "no. of highest sum blocks" to be found also as an user input (call it 2). Based on these two user inputs I want to arrive the formula/macro to find the top no. of blocks and give the Max of sum of each block, Min of sum of each block and the Average of sum of each block. Here if the user defines the block size as 10, then the no. of blocks can be maximum 15 as 10*15 is 150 which is less than 156 cells available, the moment users provides no. of blocks as 16, it needs to have minimum 160 cells. Similarly for a block size of 8 the no. of blocks can be maximum 19, 8*19 is 152.
I hope I have not made the situation too complex. Both excel formula (with or without helper cells, preferably with minimum helper cells :) ) and VBA code are equally welcome as a solution to this problem. I am treating this as an extension to the original problem, so not posting this as a new thread for now, hope it gets attention from the super users on this community, thanking in advance

Book28
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZEAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZFAFB
1
2Week1Week2Week3Week4Week5Week6Week7Week8Week9Week10Week11Week12Week13Week14Week15Week16Week17Week18Week19Week20Week21Week22Week23Week24Week25Week26Week27Week28Week29Week30Week31Week32Week33Week34Week35Week36Week37Week38Week39Week40Week41Week42Week43Week44Week45Week46Week47Week48Week49Week50Week51Week52Week53Week54Week55Week56Week57Week58Week59Week60Week61Week62Week63Week64Week65Week66Week67Week68Week69Week70Week71Week72Week73Week74Week75Week76Week77Week78Week79Week80Week81Week82Week83Week84Week85Week86Week87Week88Week89Week90Week91Week92Week93Week94Week95Week96Week97Week98Week99Week100Week101Week102Week103Week104Week105Week106Week107Week108Week109Week110Week111Week112Week113Week114Week115Week116Week117Week118Week119Week120Week121Week122Week123Week124Week125Week126Week127Week128Week129Week130Week131Week132Week133Week134Week135Week136Week137Week138Week139Week140Week141Week142Week143Week144Week145Week146Week147Week148Week149Week150Week151Week152Week153Week154Week155Week156
3Sales Qty -->266345259244250156493332160375244191344220334288324375322208219344313632653151862943983413516637644190193437316327437116529063194385345350972981232121582506918319035939829130101803632842623923177617321017632614027835765143302281135781692531091792529999295241793521761515933953121329279162517138931728016335496272242107343602141873573081781784883134257231343361115112382709796122208378257134154372179381293228161346128751277832375282247
4Yellow indicates User Input, always an integer
5Green indicates, formula/answer needed in this cell
6
7User Input
81. Block Size (No. of continuous cells in a block)6
92. No. of Non Overlapping Blocks (Highest Sum block as Block#1 and likewise)4
103. Out of above defined no. of blocks (Point 2 above), sum of block holding maximum sum400
114. Out of above defined no. of blocks (Point 2 above), sum of block holding minimum sum280
125. Out of above defined no. of blocks (Point 2 above), average of the sum of each block335
13
14Illustration of expected Answers:
15Assume Block 1 Sum is400
16Assume Block 2 Sum is360
17Assume Block 3 Sum is300
18Assume Block 4 Sum is280
Sheet1
Cell Formulas
RangeFormula
D10D10=MAX(C15:C18)
D11D11=MIN(C15:C18)
D12D12=AVERAGE(C15:C18)
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

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