Hi,

please make sure to have a worksheet "Result" in the workbook where the avg will be written into columns A and B if the difference of the avg and the median is not greater than 8.
Sub Macro1()

    Application.ScreenUpdating = False
    
    Dim LastRow As Long, t As Long, q As Long
    Dim avgt As Double
    
    With ThisWorkbook.Worksheets("Data")
        LastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
        
        For t = 3 To LastRow - 2

            avgt = (.Cells(t - 2, 2).Value + .Cells(t - 1, 2).Value + .Cells(t + 1, 2).Value + .Cells(t + 2, 2).Value) / 4
'            Debug.Print avgt - .Cells(t, 2).Value
            If avgt - .Cells(t, 2).Value <= 8 And avgt - .Cells(t, 2) >= -8 Then
'                MsgBox t - 2 & " to " & t + 2 & ": " & avgt
                q = ThisWorkbook.Worksheets("Result").Cells(ThisWorkbook.Worksheets("Result").Rows.Count, 1).End(xlUp).Row + 1
                ThisWorkbook.Worksheets("Result").Cells(q, 1).Value = t - 2 & " to " & t + 2
                ThisWorkbook.Worksheets("Result").Cells(q, 2).Value = avgt
            End If
            
        Next t

    End With
    
    Application.ScreenUpdating = True
    
End Sub
Regards