I have altered it a little to make it so that it puts the formula in the
first empty cell in column L. Im stll having troubble trying to make it loop
through and find all of the data that meets the ,ten minute and only uses the
data once restriction.
Sub macro3()
Dim top 'first cell
Dim tlength 'difference between top and top + 60
Dim tstart 'starting time
Dim Boto
top = 1
While top < 64000 ' give it a way out of loop, adjust to your sheet lower if
you have smaller files.
Cells(top, 1).Select 'grab first cell
tstart = ActiveCell.Value
Boto = Cells(top + 60, 1).Select 'grab 60 cells later
tlength = Boto - tstart 'calculate time diff
If tlength < 0.006956018 Then 'for some reason this is greater than 10min
Cells(Rows.Count, 12).End(xlUp).Offset(1, 0).Activate 'first empty cell in L
Selection.Formula = "=average(e" & top & ":e" & (top + 60) & ")" 'string to
put in l1 as formula
top = 65000 'exit strategy
End If
top = top + 1 'increment row number.
Wend
End Sub
--
Message posted via
http://www.officekb.com