Finding average for any number of rows

Closed
Brad - 1 Jul 2009 à 08:22
Excelguru Posts 261 Registration date Saturday 11 April 2009 Status Member Last seen 21 June 2011 - 1 Jul 2009 à 22:52
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 11 April 2009 Status Member Last seen 21 June 2011 307
1 Jul 2009 à 08:36
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
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.
Excelguru Posts 261 Registration date Saturday 11 April 2009 Status Member Last seen 21 June 2011 307
1 Jul 2009 à 22:52
Hi Brad

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