VBA's Round function is not as capable (unless improved in 2007) as the
worksheet ROUND function. In particular:
- VBA Round does not support Digits<0
- VBA Round is not well buffered against binary differences that have no
impact on the 15 decimal digit display, and so will sometimes produce
unintended results.
The VBA code I posted several years ago
http://groups.google.com/group/micro...7fce6145b70d69
addresses both of these issues.
Jerry
"Ron Rosenfeld" wrote:
On Fri, 20 Feb 2009 13:50:01 -0800, riffmastr7
wrote:
Hi, I need to apply the rounding rule below for conducting our business when
dealing with a number that has a 0.5 ending:
Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.
Please help! Thanks.
It can be done easily with a UDF since VBA uses the so-called Banker's rounding
algorithm.
To enter the UDF, <alt-F11 opens the VB Editor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.
To use it, enter a formula like =RndToEven(num, Digits)
==========================
Function RndToEven(num As Double, Digits As Long) As Double
RndToEven = Round(num, Digits)
End Function
========================
--ron