Sum Last 4 numbers in a column with dynamic number of blanks between the numbers

ramjet81

New Member
Joined
Jun 2, 2013
Messages
10
I have hurt my brain trying to figure this one out. I need to be able to sum the last four numbers in Column A. The number of blank cells between the numbers are dynamic. I have tried to look at the following functions: INDEX, COUNT, COUNTIF, FREQUENCY, etc.

Help!!! Anyone got an idea on how to solve?

Thanks

AB
1DataSum of Last 4 Numbers
2
3215
4
5
6616
7
8
9
10312
11
12
13410
14
153
16
17
182
191

<tbody>
</tbody>
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Excel 2010
AB
1DataSum of Last 4 Numbers
2
3215
4
5
6616
7
8
9
10312
11
12
13410
14
153
16
17
182
191
Sheet5 (4)
Cell Formulas
RangeFormula
B3{=IF(AND(A3<>"",ISERROR(SMALL(IF(A3:A19<>"",ROW(A3:A19)),4))=FALSE),SUM(A3:INDEX($A$1:A19,SMALL(IF(A3:A19<>"",ROW(A3:A19)),4))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Sheetspread,

This did the trick for me. I have to go back and study the application of the "small" function in this formula and the application of the Array calculation so I can learn from this. Thank you so much.

ramjet81
 
Upvote 0
Thanks, Salim.

That is another interesting approach in the Video. I will check that out too.

ramjet81
 
Upvote 0
I have to go back and study the application of the "small" function in this formula and the application of the Array

You understand most of it already. You're selecting the four smallest (nearest) nonblank row numbers below and including the current nonblank cell in column A. You would use frequency for filtering unique values or something similar.
 
Upvote 0
I savvy. Was this solution one that you had already solved before, or did you conceive the solution that quick? I'm impressed. I was trying to figure out how to count down to the last four non-blank numbers. Your solution was ingenious. Thank you very much.
 
Upvote 0
I've seen similar versions of this problem so it just took a few tries to work exactly. Ctrl-Shift-Enter formulas are often needed to overcome the limits of sum/countif(s) and even sumproduct.
 
Upvote 0

Forum statistics

Threads
1,216,459
Messages
6,130,758
Members
449,588
Latest member
accountant606

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