Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would change your line " Boto = Cells(top + 60, 1).Select 'grab 60 cells
later to "Boto = Cells(top + 60, 1).Value 'grab 60 cells later" when I run your macro Boto = True instead of a real number. (might work for you if you have a different edition of XL, I suppose) I would change "top = 65000 " to "top = top + 60" so it continues with the next 10 min of data. I suppose you can change the while top < 64000 line to something else like while(tlength 0) because if the bottom cell is null or zero, you will get a negative value. I noticed it will average the last bit of data once it reaches the empty cells, so you may have less than 60 cells in the last average in the L column. I am sure you can add another if statement to avoid that. I just tested this, it rips right through the time column and spits out averages of 60 cells of E into the L column. "mrc1986 via OfficeKB.com" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|