You have a function in Excel 2010 I don't have in Excel03 which should be making this whole thing quite easy for you, a formula function called AVERAGEIF(). It's like a SUMIF() but for averaging.
Anyway, this macro takes advantage of this function and creates a simple table in columns Q:R based on the data in columns A:F.
Sub AverageSpeed()
Dim M As Long
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
M = Application.WorksheetFunction.Max(Range("A:A"))
With Range("G2:G" & LR)
.FormulaR1C1 = "=IF(ISNUMBER(RC1), (R[1]C3-RC3)/(R[1]C2-RC2), """")"
.Value = .Value
End With
Range("Q1:R1").Value = [{"Frame","Average"}]
Range("Q2") = 0
Range("Q3").Resize(M).FormulaR1C1 = "=R[-1]C + 1"
Range("R2:R" & M + 2).FormulaR1C1 = "=AVERAGEIF(R1C1:R" & LR & "C1, RC[-1], R1C7:R" & LR & "C7)"
End Sub
Bookmarks