How do I modify rounding rules in Excel?

M

merritaf

I would like to have excel use a modified rounding rule, where when a
calculation anwers has a '.5' value the odd numbers rounded up to next whole
number and even numbers are rounded down.....(example 13.5 would be rounded
up to 14 and 4.5 would be rounded down to 4). I need to have ecel do a
computation and then apply this rounding rule.
 
M

Myrna Larson

If you are interested in a more general solution (rather than just rounding to
an integer), you can take advantage of the fact that VBA's Round function
works this way. This is sometimes referred to as 'Banker's rounding', as it
eliminates bias (half the time the .5 is rounded up, half the time down).

The following VBA function will apply those rounding rules. The code is a bit
more complicated than you might expect, since Excel's ROUND worksheet function
accommodates a negative number of decimal places and and VBA doesn't, and I
wanted them to work the same other than the handling of the 0.5 issue.

Function BankersRound(Number As Double, Places As Long) As Double
Dim X As Double

If Places < 0 Then
X = 10 ^ Places
BankersRound = Round(Number * X, 0) / X
Else
BankersRound = Round(Number, Places)
End If
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Rounding 2
ROUNDING 2
Round up/down duration 0
Round up or down to nearest 5, but not 10 2
rounding a number up to a certain ending digit 6
Rounding problem 9
Round Function 5
Round formula 1

Top