Need to sum the bottom 5 cells that have values....

jasgot

New Member
Joined
Jul 16, 2002
Messages
30
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
AB
1001
1002
5003
4004
1005
2006
7
2008
1009
10010

I want to sum a maximum of the bottom five rows that have values. I want to skip the blank rows.
So the results of the formula in B10 should be 100+100+200+200+100 = 700

I will use this formula in an adjacent column to get a rolling sum of a maximum of the last five rows
Where there are not five rows, I just want the rows that have values
So the result in B1 will be 100 (A1:A1) - because there is only one row
the result in B2 will be 200 (A1:A2) - because there are only two rows
the result in B3 will be 700 (A1:A3)- because there are only three rows
the result in B4 will be 1100 (A1:A4) - because there are only four rows
the result in B5 will be 1200 (A1:A5) - because there are only five rows
the result in B6 will be 1300 (A2:A6) - because there are more than five rows
the result in B7 will be 1300 (A2:A6) - because we had to go up one more to get 5 values because A7 is empty
the result in B8 will be 1400 (A3:A8) - because we had to go up one more to get 5 values because A7 is empty
the result in B9 will be 1000 (A4:A9) - because we had to go up one more to get 5 values because A7 is empty
the result in B10 will be 700 (A5:A10) - because we had to go up one more to get 5 values because A7 is empty

I need the formula to determine which rows should be included (they must have a value) because I cannot hard code the range like I did here.

The goal is to sum the most recent five values, there may actually be several blanks that have to be skipped (sometimes).

Thanks.

Jason
 
I stand corrected; I assumed it was an array formula issue; I don't have time to look at it right now, so I'll check in again later
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I stand corrected; I assumed it was an array formula issue; I don't have time to look at it right now, so I'll check in again later
I really appreciate you taking the time to help. This is really driving me nuts. It should work, it's not an obscure set of functions.
 
Upvote 0
Try this

23 08 03.xlsm
AB
1100100
2100200
3500700
44001100
51001200
62001300
7 
82001400
91001000
10100700
Sum last 5
Cell Formulas
RangeFormula
B1:B10B1=IF(A1="","",SUM(INDEX(A$1:A1,LARGE(IF(A$1:A1<>"",ROW(A$1:A1)-ROW(A$1)+1),MIN(5,COUNT(A$1:A1)))):A1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Solution
That works a treat! Thank you so much!!!!
Can I buy you a drink?

Try this

23 08 03.xlsm
AB
1100100
2100200
3500700
44001100
51001200
62001300
7 
82001400
91001000
10100700
Sum last 5
Cell Formulas
RangeFormula
B1:B10B1=IF(A1="","",SUM(INDEX(A$1:A1,LARGE(IF(A$1:A1<>"",ROW(A$1:A1)-ROW(A$1)+1),MIN(5,COUNT(A$1:A1)))):A1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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