View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.newusers
Jerry W. Lewis
 
Posts: n/a
Default average last 17 cells (variable)

Much clearer, thanks. Domenic has given one possible formula; here is another

=AVERAGE(IF((COLUMN(C3:IV3)=LARGE(IF(ISNUMBER(C3: IV3),COLUMN(C3:IV3)),A1))*ISNUMBER(C3:IV3),C3:IV3) )

both must be array entered (Ctrl-Shift-Enter).

The two formulas will give different results if there is non-numeric data
among the numeric data. Dominic's formula will average the last cell that
has anything in it (other than a zero length string) together with the
preceding A1-1 non-empty cells, whether numeric or not. My formula will
average the last A1 numeric values, even if it has to skip over some cells to
find A1 numeric values.

Your call which approach is more in keeping with your needs.

Jerry

"Brian Thompson via OfficeKB.com" wrote:
....
Hit me on the head and call me stupid ! I got a little flustered when typing

I am working out the average hrs of employees for the WTD (Working time
directive). Currently attempting to work out the last 17 weeks, however,
later this may turn to be 26 weeks if "Opt out" is agreed.

Cell A1 = number of last weeks to average, ignoring blanks cells
Cell A3 = Name
Cell B3 = Result of last 17 weeks
Cell C3 = Hrs
Cell D3 = Hrs
Cell E3 = Hrs
Etc, Etc

If it is not possible to enter a variable in A1, then I will go with the
fixed 17 weeks

Hope this is clearer?