Find sum of next three column values (observations) after SUM of previous observations reached a certain level

smide

Board Regular
Joined
Dec 20, 2015
Messages
162
Office Version
  1. 2016
Platform
  1. Windows
Hello.

In column B I have a list of values (observations) and in column C I calculated the sum of those observations.
Somehow I need a sum of next three observations after SUM in COLUMN C (TOTAL) reached certain level (number).

Example.

Finding sum of next three values in column B, after Total (column C) reached at least ten (10) or more.
Result(s) should be placed in column E (E2:E).
Input cell (which contains required "level", 10 in this case) is cell D2.

ABCDEF
1Observations
Sum of Observations
required "level"
Results
...
22210-8
368-2
4-17
5512
6-48
7311
8-74
926
1039
11-27
12.......
13.......
14.......

<tbody>
</tbody>
Results in column E (adding values from column B): -4+3-7 = -8 , (B6+B7+B8)
-7+2+3= -2 , (B8+B9+B10)
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Could you explain what the column D is supposed to represent, the "level"?

How have you decided where your total numbers matter? I assume it is only after the bold ones that you want to use in working out your E column?
 
Last edited:
Upvote 0
Could you explain what the column D is supposed to represent, the "level"?

How have you decided where your total numbers matter? I assume it is only after the bold ones that you want to use in working out your E column?

Yes, "after" is key word.
The "bold ones" (in column C - SUM column) are those equal or more than "required level" , number ten (10) in cell D2 of my example (which of course I choose arbitrarily).
 
Upvote 0
This code should work. Will need to be run each time any data is added/changed:

Code:
Sub Results()

Dim Level As Double
Dim i As Integer
Dim j As Integer

Level = Range("D2").Value
j = 2

For i = 2 To Range("C2").End(xlDown).Row
    If Cells(i, 3) >= Level Then
        Cells(j, 5).Value = Cells(i + 1, 2).Value + Cells(i + 2, 2).Value + Cells(i + 3, 2).Value
        j = j + 1
    End If
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,845
Members
449,471
Latest member
lachbee

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