Thread: macro help
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default macro help

This should match the example given

Sub averageemup()
Columns("b:c").ClearContents

For i = 1 To Cells(rows.Count, "a").End(xlUp).Row - 9
Cells(i + 4, "b").Value = _
Application.Average(Range(Cells(i, "a"), Cells(i + 4, "a")))
Next i

For i = 5 To Cells(rows.Count, "b").End(xlUp).Row - 5
Cells(i + 5, "c").Value = _
Application.Average(Range(Cells(i, "b"), Cells(i + 4, "b")))
Next i

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"scott" wrote in message
...
My task is is pretty simple, but complicated to explain, so bear with me.
I
am taking a column of data (column a), and taking the average of every 5
data
points (column b), starting at a1. In column c, I am taking the average
of
every 5 data points in column b, starting with b5. I would like to create
a
macro that will do this for me, but I am having trouble figuring out how
to
do it. See below for my example.

a b c
1. 1
2. 2
3. 3
4. 4
5. 5 3
6. 6 4
7. 7 5
8. 8 6
9. 9 7
10. 10 8 5
11. 11 9 6
12. 12 10 7
13. 13 11 8
14. 14 12 9
15. 15 13 10
16. 16
17. 17
18. 18
19. 19
20. 20

can anyone help? i'll explain better if you need me to.