View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jay
 
Posts: n/a
Default Function for generating monthly & weekly averages

Try putting these in row 1 and copying down for as many rows as you
need.

C1: =IF(E1=E2,"",SUMIF(E:E,E1,B:B)/COUNTIF(E:E,E1))

D1: =IF(F1=F2,"",SUMIF(F:F,F1,B:B)/COUNTIF(F:F,F1))

E1: =WEEKNUM(A1)

F1: =MONTH(A1)

The averages appear for the last day of each week or month.


Thank you Jay! That is exactly what I was looking for!


Two words of caution, though.

1. If your data spans more than 51 weeks, there'll be a problem because C1
goes by week of a year.

2. The calculation assumes that the week containing New Years Day is meant
to be split in two.

Adjustments for these potential pitfalls are straightforward. ;-)