View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default average for new date

VBA solution:

Averages are written to "Sheet2" with dates


Sub Average_dates()
Dim lrow As Long, r As Long, rr As Long, dte As Date
Dim n As Integer
With Worksheets("Sheet1")
lrow = .Cells(Rows.Count, "A").End(xlUp).Row
r = 2
rr = 1
Do
dte = .Cells(r, "A")
n = Application.CountIf(.Range("A:A"), dte)
rr = rr + 1
Worksheets("Sheet2").Cells(rr, "A") = dte
Worksheets("Sheet2").Cells(rr, "B") = Application.Average(.Cells(r,
"B").Resize(n, 1))
r = r + n
Loop Until r lrow
End With

End Sub

"Hans Knudsen" wrote:

Until someone comes up with a more simple solution you might want
to try the following monster:

=IF(NOT(ISERROR(IF(COUNTIF(A1:A$26000,A1)1,"",SUM IF(A:A,A1,B:B))/IF(COUNTIF(A1:A$26000,A1)1,"",COUNTIF(A:A,A1)))), IF(COUNTIF(A1:A$26000,A1)1,"",SUMIF(A:A,A1,B:B))/IF(COUNTIF(A1:A$26000,A1)1,"",COUNTIF(A:A,A1)),"" )

Hans



"little bear" skrev i en
meddelelse
...
I have a table of dates and values with a different number of rows
for each
date, and i would like to average over each date no matter how
many rows
there are for each date. the data look like:
7/1/06 1
7/1/06 2
7/1/06 3
7/2/06 5
7/2/06 3
7/3/06 9
7/4/06 1
7/4/06 2

so what i need to do is increment the date and calc the average
of all the
corresponding values for that date, then go to the next date,
etc. there are
26,000 rows of data. Thank you very much!