Finding average for any number of rows

Closed
Brad - Jul 1, 2009 at 08:22 AM
Excelguru Posts 261 Registration date Saturday April 11, 2009 Status Member Last seen June 21, 2011 - Jul 1, 2009 at 10:52 PM
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 responses

Excelguru Posts 261 Registration date Saturday April 11, 2009 Status Member Last seen June 21, 2011 307
Jul 1, 2009 at 08:36 AM
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
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.
0
Excelguru Posts 261 Registration date Saturday April 11, 2009 Status Member Last seen June 21, 2011 307
Jul 1, 2009 at 10:52 PM
Hi Brad

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