View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Calculate average pay from highest five consecutive years

Perhaps over simple, but can you sort the data on Amount
within Employee value. Then the top 5 (or less ?) would be
at the top.
A new column could identify a change in employee number
(i.e. if not the same as the one above) and average the
next 5 columns of Amount
=if(A5<A6,(C1+c2+c3+c4+c5)/5,"") in column D

Would need adjusting if the Employee had less that 5 years
data though. Alternatively build it into a macro/VBA
script.
-----Original Message-----
I have a workbook with two worksheets

Worksheet #1 has the following:

Employee# Year Amount
12345 2002 40000
12345 2001 26390
12345 2000 33184
12345 1999 38861
12345 1998 25198
12345 1997 32015
98765 2002 67923
<etc etc etc etc

Worksheet #2 has a cell that I need to put the average of

the five
highest years of pay for each employee record.

Any ideas how to write this function?

Thanks in advance.

Chris
.