I need to write a macro on my Excel sheet to calculate the average of cells for me. This is the code I have written but the average function is not working.
Can you please let me know how can I use the Average function in my code.
Thanks alot
Expand|Select|Wrap|Line Numbers
- Sub Macro1()
- Ncol = 1
- nrowColumn2 = 1
- i = 1
- Do Until IsEmpty(Worksheets(1).Cells(i, 1))
- j = i + 7
- Worksheets(1).Cells(i, 2).Select
- ActiveCell.Value2 = "=
- AVERAGE(Worksheets(1).Cells(i,1).value2:Worksheets(1).Cells(j,1).value2)"
- Modi = i Mod 3
- If Modi = 0 Then
- i = i + 10
- Else
- i = i + 1
- End If
- nrowColumn2 = nrowColumn2 + 1
- Loop
- End Sub