View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default mean calculation of each column of each group

I assume when you say MEAN you mean AVERAGE and not MEDIAN.

Sub MakeGroups()

RowCount = 3
FirstRow = RowCount
Do While Range("E" & RowCount) < ""
If Range("E" & RowCount) < Range("E" & (RowCount + 1)) Or _
Range("F" & RowCount) < Range("F" & (RowCount + 1)) Or _
Range("G" & RowCount) < Range("G" & (RowCount + 1)) Then

Rows(RowCount + 1).Insert
Rows(RowCount + 1).Insert
Rows(RowCount + 1).Insert
Rows(RowCount + 1).Insert
Rows(RowCount + 1).Insert

Range("I" & (RowCount + 1)).Formula = _
"=Average(I" & FirstRow & ":I" & RowCount & ")"
Range("I" & (RowCount + 1)).Copy _
Destination:=Range("I" & (RowCount + 1) & ":BN" & (RowCount + 1))

RowCount = RowCount + 6
FirstRow = RowCount
Else
RowCount = RowCount + 1
End If
Loop

End Sub


"climate" wrote:

Hi
I have a matrix on sheet1 (2000 * 60), I2 TO BN2001, ,columns E,F,G is date
(year,month,day).
First row I2 to BN2 is labled.i sorted this matrix based on column G
(day)descending and expanded.
Then sorted again, based on column F (month) ascending and expanded.
As a result, my matrix is sorted and classified to many groups. for example:
first group include all days (31 Jan) of all years, and second group include
all days (30 Jan) all of years.
I need to a macro, when i run it,at first separate groups with 5 blank rows,
and then calculate mean of any column in each group and write
them(mean)under any column in to the first blank row.

Would you please help me, because i have 60 worksheet similar above, and
manual arrangment and calculation need to spend very time.

best regards