OK, try it, the comments are quite explicit to explain things.
Code:
Sub Avg()
Dim DerCol As Long, c As Long, MySom As Long, MyNb As Long, MyAvg
As Long, r As Long
DerCol = Sheets("File1").Cells(2, Rows(2).Cells.Count).End(xlToLeft).Column 'retrieves the last column filled on the basis of line 2
For r = 3 To 22 'Loop on the lines whereas the number is fixed
For c = 7 To DerCol Step 2 'Loop column 7 (G) filled with the last jump of 2, it means that the following loop c will be worth 9, then 11, ...
MySom = MySom + Cells(r, c) 'Sum the value of the variable line every 2 column by loop
MyNb = MyNb + 1 'Count the number of column (there is no choice but ...)
Next c 'Goes to the next c
Sheets("File1").Cells(r, 5) = Round(MySom / MyNb, 2)
MySom = 0
MyNb = 0
Next r
For r = 3 To 22 'Loop on the lines whereas the number is fixed
For c = 8 To DerCol Step 2 'Loop column 8 (H) to the last filled with jumps of 2, it means that the following loop c will be worth 9, then 11, ...
MySom = MySom + Cells(r, c) 'Sum the value of the variable line every 2 column by loop
MyNb = MyNb + 1 'Count the number of column (there is no choice but ...)
Next c 'Goes to the next c
Sheets("File1").Cells(r, 6) = Round(MySom / MyNb, 2)
MySom = 0
MyNb = 0
Next r
End Sub
Bookmarks