View Single Post
  #3   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default sum of last 7 numbers

On Sat, 12 Nov 2005 07:39:33 -0600, tzvarza`
wrote:


I have a row where I enter a number every day. I need a cell which shows
the sum of the last 7 entered numbers.

For example, if I have the numbers 7 2 4 11 5 4 2 6, the cell must show
28 (11+5+4+2+6)



Not sure exactly what you want. In your text, you want the sum of the last 7;
but in your example, you are only summing the last 5.

Assumptions:
1. SUM formula is in cell A2
2. Data is in B2:IV2
3. Data is entered consecutively with no intervening blanks that need to be
ignored.
4. nums = the number of most recent entries to be SUM'd (5 or 7 or whatever)

The **array entered** formula:

=IF(COUNT(B2:IV2)<=nums,SUM(B2:IV2),SUM(OFFSET(A2, 0,-1+MAX(ISNUMBER(B2:IV2)*COLUMN(B2:IV2)),1,-nums)))

To **array-enter** a formula, after typing/pasting it into the formula bar,
hold down <ctrl<shift while hitting <enter. Excel will place braces {...}
around the formula.




--ron