Finding average for any number of rows

Closed
Report
-
Posts
261
Registration date
Saturday April 11, 2009
Status
Member
Last seen
June 21, 2011
-
Hello,

So i have three coloumns filled with data, which can have any number of rows. i want to build a macro that will find the average of the three columns in other column (the fourth column next to them). then have the macro autofill until the last row with data in it. it needs to be an excel macro with the application im working with. here is what i have so far and please feel free to ask me any questions.


Sub avgtest()
'
' avgtest Macro
' Macro recorded 7/1/2009 by Administrator
'

'
v = [E65536].End(xlUp).Row
b = 3
Range("F3").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-4]:RC[-1])"
Range("F3").Select
Selection.AutoFill Destination:=Range(Cells(b, 2), Cells(v, 5)), Type:=xlFillDefault
End Sub

3 replies

Posts
261
Registration date
Saturday April 11, 2009
Status
Member
Last seen
June 21, 2011
307
Hi Brad

From your message, it seems that you have data in columns CD&E
So instead of Selection.AutoFill Destination:=Range(Cells(b, 2), Cells(v, 5)), Type:=xlFillDefault
put Selection.AutoFill Destination:=Range(Cells(3, 5), Cells(v, 5)), Type:=xlFillDefault
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

I had just changed that right as you emailed me however i still get a debug error, excel doesn't like the format thats inside of the range function.
Posts
261
Registration date
Saturday April 11, 2009
Status
Member
Last seen
June 21, 2011
307
Hi Brad

using msgbox find the value of v and is that correct
and check whether F3 have any formula