Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have written some code to find out average of some
numbers. Although if i used Excel's existing formula, average, to work it out, the result would be different (about less than 1% for an average of 720 numbers) from that derived using my own code. I wonder if the difference is due to rounding errors. Is it possible to take a look at the code behind Excel's existing formulas? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, it isn't possible. But I suspect the error is on your end <bg.
On Wed, 29 Sep 2004 18:35:53 -0700, "Darren" wrote: I have written some code to find out average of some numbers. Although if i used Excel's existing formula, average, to work it out, the result would be different (about less than 1% for an average of 720 numbers) from that derived using my own code. I wonder if the difference is due to rounding errors. Is it possible to take a look at the code behind Excel's existing formulas? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the reply.
Do you know then, the syntax to use if i want to use Excel's average formula for col A, rows i to j? rows i and j? If i and j are both variables Thanks Darren -----Original Message----- No, it isn't possible. But I suspect the error is on your end <bg. On Wed, 29 Sep 2004 18:35:53 -0700, "Darren" wrote: I have written some code to find out average of some numbers. Although if i used Excel's existing formula, average, to work it out, the result would be different (about less than 1% for an average of 720 numbers) from that derived using my own code. I wonder if the difference is due to rounding errors. Is it possible to take a look at the code behind Excel's existing formulas? . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use most worksheet functions within your VBA code. Exceptions are
cases where VBA has its own function that does the same thing, but that doesn't apply to AVERAGE. The syntax is Set Rng = Cells(i, 1).Resize(j - i + 1, 1) Avg = Application.Average(Rng) or, putting it all into one statement: Avg = Application.Average(Cells(i, 1).Resize(j - i + 1, 1)) On Wed, 29 Sep 2004 21:14:20 -0700, "Darren" wrote: Thanks for the reply. Do you know then, the syntax to use if i want to use Excel's average formula for col A, rows i to j? rows i and j? If i and j are both variables Thanks Darren -----Original Message----- No, it isn't possible. But I suspect the error is on your end <bg. On Wed, 29 Sep 2004 18:35:53 -0700, "Darren" wrote: I have written some code to find out average of some numbers. Although if i used Excel's existing formula, average, to work it out, the result would be different (about less than 1% for an average of 720 numbers) from that derived using my own code. I wonder if the difference is due to rounding errors. Is it possible to take a look at the code behind Excel's existing formulas? . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
PS: You really ought to study your code to see why you are getting a different
answer. You always learn something from "debugging". Are you sure this isn't just a rounding issue? If the cells on the worksheet are the result of formulas, but displayed with, say, 2 decimal places, when you use the AVERAGE formula, the complete number is used, not the rounded version that you see. If you are working with the rounded numbers in your code, you'll get a different result. On Wed, 29 Sep 2004 21:14:20 -0700, "Darren" wrote: Thanks for the reply. Do you know then, the syntax to use if i want to use Excel's average formula for col A, rows i to j? rows i and j? If i and j are both variables Thanks Darren -----Original Message----- No, it isn't possible. But I suspect the error is on your end <bg. On Wed, 29 Sep 2004 18:35:53 -0700, "Darren" wrote: I have written some code to find out average of some numbers. Although if i used Excel's existing formula, average, to work it out, the result would be different (about less than 1% for an average of 720 numbers) from that derived using my own code. I wonder if the difference is due to rounding errors. Is it possible to take a look at the code behind Excel's existing formulas? . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
A formula to AVERAGE IF but only average a set number of values | Excel Worksheet Functions | |||
Find monthly average but have average automatically configured | Excel Discussion (Misc queries) | |||
Error Handling #N/A with AVERAGE Function - Average of values in Row | Excel Worksheet Functions | |||
Weighed Average of a weiged average when there are blanks | Excel Discussion (Misc queries) | |||
how does one convert text to a formula "average(A:A)" to =average( | Excel Worksheet Functions |