Search : in
By :

Finding average for any number of rows

Last answer on Jul 2, 2009 3:52:54 am BST Brad, on Jul 1, 2009 1:22:27 pm BST 
 Report this message to moderators

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

Configuration: Windows XP Internet Explorer 7.0 excel 2003

Best answers for « finding average for any number of rows » in :
How to change XP Serial/License number ShowHow to change XP Serial/License number Go to / Start Menu/ Run/ Type regedit and click OK. Before any operation in the registry, he should make a backup of the registry as a precaution In the Registry Editor, click File...
[C Language] finding the square root of a number Show[C Language] finding the square root of a number Intro Notes Intro A simple C program allowing you to find the square root of a number. #include #include int main(void) { double x = 4.0, result;...
Phpize: command not found Showphpize: command not found Though you have installed the PHP programming language on your computer, you will be required to install the extension pecl to be able to run its commands. Else, you will be face with the error message...
TCP protocol ShowThe characteristics of TCP protocol TCP (which means Transmission Control Protocol) is one of the main protocols of the transport layer of the TCP/IP model. It makes it possible, at application level, to manage data coming from (or going to) the...
NAT- Network address translation, port forwarding and port trigg ShowThe principle of NAT Network address translation or NAT was developed in order to respond to the shortage of IP addresses with IPv4 protocol (in time the IPv6 protocol will respond to this problem). In fact, in IPv4 addressing the number of...

1

Excelguru, on Jul 1, 2009 1:36:40 pm BST
  • +1

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
Winners are losers who got up and gave it one more try. -Dennis DeYoung
My Interests are financial Modelling and custom excel development.

Reply to Excelguru

2

Brad, on Jul 1, 2009 1:41:49 pm BST

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.

Reply to Brad

3

 Excelguru, on Jul 2, 2009 3:52:54 am BST

Hi Brad

using msgbox find the value of v and is that correct
and check whether F3 have any formula Winners are losers who got up and gave it one more try. -Den­nis DeYoung
My Interests are financial Modelling and custom excel develo­pment.

Reply to Excelguru