Sum last N values

betgem

New Member
Joined
Apr 21, 2009
Messages
15
Hi, everyone !

I have a column with a formula that returns a number or a FALSE.

1 FALSE
2 FALSE
3 0
4 FALSE
5 FALSE
6 FALSE
7 1
8 FALSE
9 FALSE
10 FALSE
11 2
12 FALSE
13 6
14 FALSE
15 FALSE

Now, the pattern of numbers and FALSE's is irregular, over hundreds of rows.

What I need is a formula that returns the sum of the last 4 numbers (not last 4 cells, which can all be FALSE).
The formula will be copied in every cell in the adjacent column, so in the example above, assuming the data is in column A, cell B14 should return a value of 9 (last 4 numbers from the A column, starting from the same row as the formula/cell in column B, and going back as many cells as required to have the sum of the last 4 numbers). Cell B15 in the above example should return 9 again, and so on.

Thank you in advance, any ideas/suggestions will be appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
A​
B​
C​
D​
1​
0​
14​
C1: {=SUM(A20:INDEX(A:A, LARGE(ISNUMBER(A1:A20) * ROW(A1:A20), 4)))}
2​
FALSE​
3​
4​
4​
8​
5​
0​
6​
5​
7​
2​
8​
FALSE​
9​
FALSE​
10​
3​
11​
2​
12​
FALSE​
13​
FALSE​
14​
FALSE​
15​
FALSE​
16​
FALSE​
17​
FALSE​
18​
FALSE​
19​
7​
20​
FALSE​

The curly braces around the formula indicate that it MUST be confirmed with Ctrl+Shift+Enter instead of just Enter. That will make the braces appear; you can't enter them manually.
 
Upvote 0
Shg, thank you for the reply. The formula worked very well, does exactly what I wanted (just had to alter the first part of the range reference to an absolute one, so that I can "anchor" it to the top cell in my row before pasting the formula down the rows/cells).
Much appreciated :)
 
Upvote 0

Forum statistics

Threads
1,215,389
Messages
6,124,662
Members
449,178
Latest member
Emilou

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