Both round to the nearest rounded number. The difference is in how ties are
handled. VBA Round follows the ASTM standard with unbiased rounding
(sometimes called "Banker's Rounding" for reasons that remain mysterious)
http://en.wikipedia.org/wiki/Unbiase...to-even_method
whereas the worksheet round function always rounds ties up.
Jerry
"Jay" wrote:
Hi Tom -
What's the underlying difference between 'Round' and 'Application.Round' ?
Here's a utility to test the preformance of each. It detects a difference
between the two methods when rounding a number with a right-most digit of
"5", but I don't undrestand the fundamental reason why:
Sub rTest()
Dim icount As Long
Dim a As Double
Dim b As Double
Dim r1 As Double
Dim r2 As Double
Randomize
Do While diff = 0
icount = icount + 1
a = Rnd()
b = Rnd()
On Error Resume Next 'trap division by zero
r1 = Round(a / b, 0)
r2 = Application.Round(a / b, 0)
On Error GoTo 0
diff = r1 - r2
Loop
MsgBox "Iteration = " & Format(icount, "#,##0") & Chr(13) & Chr(13) & _
"a = " & a & Chr(13) & _
"b = " & b & Chr(13) & _
"a / b = " & Format(a / b) & Chr(13) & Chr(13) & _
"Round = " & r1 & Chr(13) & _
"Application.Round = " & r2 & Chr(13) & _
"diff = " & r1 - r2
End Sub
--
Jay
"Tom Ogilvy" wrote:
NamesPerSlip = Round(ActiveCell.Offset(0, -3) / ActiveCell.Offset(0, -2),0)
if you like the way the worksheet rounds
NamesPerSlip = Application.Round(ActiveCell.Offset(0, -3) /
ActiveCell.Offset(0, -2),0)
--
Regards,
Tom Ogilvy
"Steve C" wrote:
Upon dividing one cell by another, I want to store the result in a variable
that is rounded to the nearest whole number (6.5 = 7, 6.2 = 6, etc.).
My basic formula is:
NamesPerSlip = ActiveCell.Offset(0, -3) / ActiveCell.Offset(0, -2)
Rounding NamesPerSlip up or down as needed is my challenge. Thanks as always!
--
Steve C