I am try to reduce data using a rolling average. I am suppose to take the average of rows 1,2,4,5 and compare it to the middle row which is 3. If the average of rows 1,2,4,5 is greater than row 3 by more than 8 then I select it. I then continue the process this time if the average of rows 2,3,5,6 is greater than 4 then select it. I am trying to write a simple code which I need help. Some of my syntax might be wrong. I am a VBA newbie. I will like to copy the data to a different sheet. my code is incomplete
Sub Macro1()
Application.ScreenUpdating = False
Sheets("Data").Select
Lastrow = Range("A65536").End(xlUp).Row
For t = 3 To Lastrow
Sheets("Data").Select
avg(t) = (cell(t-2,2) + cell(t-1,2) + cell(t+2,2) + cell(t+1,2))/4
If ((avg(t)-cell(t,2))>=8) Or ((avg(t)-cell(t,2))>=-8) Then
Bookmarks