advanced average function

  • Thread starter Thread starter Patrick Molloy
  • Start date Start date
P

Patrick Molloy

try a simple for...next loop

Sub test()

Dim rw As Long, maxrow As Long
Dim Inc As Long ' offset for formula
Dim Col As String ' column for result

Inc = 10 ' used for our offset
Col = "C"
maxrow = Range("a1").End(xlDown).Row
For rw = 1 To maxrow / Inc
Cells(rw, Col).Formula = "=Average(A" & (rw - 1) * Inc
+ 1 & _
":A" & rw * Inc & ")"
Next

End Sub



Patrick Molloy
Microsoft Excel MVP
 
Patrick,

Thanks for all your help.


Patrick Molloy said:
try a simple for...next loop

Sub test()

Dim rw As Long, maxrow As Long
Dim Inc As Long ' offset for formula
Dim Col As String ' column for result

Inc = 10 ' used for our offset
Col = "C"
maxrow = Range("a1").End(xlDown).Row
For rw = 1 To maxrow / Inc
Cells(rw, Col).Formula = "=Average(A" & (rw - 1) * Inc
+ 1 & _
":A" & rw * Inc & ")"
Next

End Sub



Patrick Molloy
Microsoft Excel MVP
 
Back
Top