Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I modify rounding rules in Excel?

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default How do I modify rounding rules in Excel?

=IF(MOD(A1, 1)=0.5, INT(A1) + MOD(INT(A1), 2), ROUND(A1, 0))

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"merritaf" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default How do I modify rounding rules in Excel?

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


On Wed, 26 Jan 2005 12:17:03 -0800, "merritaf"
wrote:

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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what are the rules for a valid sheet name in excel romstep Excel Discussion (Misc queries) 11 August 25th 09 04:23 AM
Copying Rules in Excel brewster56 Excel Discussion (Misc queries) 7 February 9th 09 04:43 PM
how do I set up a validation rules with two data rules Trudy Excel Worksheet Functions 1 October 16th 06 05:42 AM
How can I alter the rounding rules? Greg Excel Worksheet Functions 3 April 15th 06 06:31 AM
I need 5 conditional formatting rules-excel only allows 3 das1997 Excel Discussion (Misc queries) 4 November 12th 05 02:33 PM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"