B
burl_rfc
I need help on the code below.
The code works great but I'd like a further enhancement but I'm not
sure what to do.
The macro selects the range of data that falls on the same day, then
for that day it then performs some statistical calculations and places
the results into columns 8 thru 15, the date is also placed into
column 7. It then goes to the next date and continues until all the
datas have been analyized.
What I'd like to do for the maxium and minimum temperature and
humidity readings, is place the actual time when they occured into
column 16 thru 19. The temp data starts at cell c3 and humidity starts
at cell d3, the date field starts at cell b3. The date field is
currently formatted as m/d/yyyy h:mn
I was thinking that sometype of cell offset might do the trick.
Cells(rowd, 16) =
Application.WorksheetFunction.Max(myRange1).cell.offset(0,-1) ' Temp
Max Time
Any help would be appreciated.
burl_rfc
Sub TempStatsDate()
Cells(1, 7) = "Date"
Cells(1, 8) = "Avg Temp"
Cells(1, 9) = "Max Temp"
Cells(1, 10) = "Min Temp"
Cells(1, 11) = "Med Temp"
Cells(1, 12) = "Avg Humidity"
Cells(1, 13) = "Max Humidity"
Cells(1, 14) = "Min Humidity"
Cells(1, 15) = "Med Humidity"
Cells(1,16) = "Temp Max Time
Row = 3
rowi = Row
rowf = Row
rowd = 2
Startdate = Cells(3, 2)
Stopdate = Startdate + 1
5 If Startdate <= Stopdate Then
Startdate = Cells(rowi, 2)
rowi = rowi + 1
rowf = rowf + 1
GoTo 5
End If
'Performes statistics on each group and summarizes information in new
location.
myRange1 = Worksheets("Sheet1").Range(Cells(rowi, 3), Cells(rowf, 3))
' Temperature column
myRange2 = Worksheets("Sheet1").Range(Cells(rowi, 4), Cells(rowf, 4))
' Humidity column
myRange3 = Worksheets("Sheet1").Range(Cells(rowi, 2), Cells(rowf, 2))
' Date column
Cells(rowd, 7) = Startdate
Cells(rowd, 8) = Application.WorksheetFunction.Average(myRange1) '
Temp avg
Cells(rowd, 9) = Application.WorksheetFunction.Max(myRange1) ' Temp
max
Cells(rowd, 10) = Application.WorksheetFunction.Min(myRange1) ' Temp
min
Cells(rowd, 11) = Application.WorksheetFunction.Median(myRange1) '
Temp med
Cells(rowd, 12) = Application.WorksheetFunction.Average(myRange2) '
Hum avg
Cells(rowd, 13) = Application.WorksheetFunction.Max(myRange2) ' Hum
max
Cells(rowd, 14) = Application.WorksheetFunction.Min(myRange2) ' Hum
min
Cells(rowd, 15) = Application.WorksheetFunction.Median(myRange2) ' Hum
med
rowd = rowd + 1
Startdate = Stopdate
Stopdate = Stopdate + 1
GoTo 5
10 End Sub
The code works great but I'd like a further enhancement but I'm not
sure what to do.
The macro selects the range of data that falls on the same day, then
for that day it then performs some statistical calculations and places
the results into columns 8 thru 15, the date is also placed into
column 7. It then goes to the next date and continues until all the
datas have been analyized.
What I'd like to do for the maxium and minimum temperature and
humidity readings, is place the actual time when they occured into
column 16 thru 19. The temp data starts at cell c3 and humidity starts
at cell d3, the date field starts at cell b3. The date field is
currently formatted as m/d/yyyy h:mn
I was thinking that sometype of cell offset might do the trick.
Cells(rowd, 16) =
Application.WorksheetFunction.Max(myRange1).cell.offset(0,-1) ' Temp
Max Time
Any help would be appreciated.
burl_rfc
Sub TempStatsDate()
Cells(1, 7) = "Date"
Cells(1, 8) = "Avg Temp"
Cells(1, 9) = "Max Temp"
Cells(1, 10) = "Min Temp"
Cells(1, 11) = "Med Temp"
Cells(1, 12) = "Avg Humidity"
Cells(1, 13) = "Max Humidity"
Cells(1, 14) = "Min Humidity"
Cells(1, 15) = "Med Humidity"
Cells(1,16) = "Temp Max Time
Row = 3
rowi = Row
rowf = Row
rowd = 2
Startdate = Cells(3, 2)
Stopdate = Startdate + 1
5 If Startdate <= Stopdate Then
Startdate = Cells(rowi, 2)
rowi = rowi + 1
rowf = rowf + 1
GoTo 5
End If
'Performes statistics on each group and summarizes information in new
location.
myRange1 = Worksheets("Sheet1").Range(Cells(rowi, 3), Cells(rowf, 3))
' Temperature column
myRange2 = Worksheets("Sheet1").Range(Cells(rowi, 4), Cells(rowf, 4))
' Humidity column
myRange3 = Worksheets("Sheet1").Range(Cells(rowi, 2), Cells(rowf, 2))
' Date column
Cells(rowd, 7) = Startdate
Cells(rowd, 8) = Application.WorksheetFunction.Average(myRange1) '
Temp avg
Cells(rowd, 9) = Application.WorksheetFunction.Max(myRange1) ' Temp
max
Cells(rowd, 10) = Application.WorksheetFunction.Min(myRange1) ' Temp
min
Cells(rowd, 11) = Application.WorksheetFunction.Median(myRange1) '
Temp med
Cells(rowd, 12) = Application.WorksheetFunction.Average(myRange2) '
Hum avg
Cells(rowd, 13) = Application.WorksheetFunction.Max(myRange2) ' Hum
max
Cells(rowd, 14) = Application.WorksheetFunction.Min(myRange2) ' Hum
min
Cells(rowd, 15) = Application.WorksheetFunction.Median(myRange2) ' Hum
med
rowd = rowd + 1
Startdate = Stopdate
Stopdate = Stopdate + 1
GoTo 5
10 End Sub