LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Rounding 0.5 to 1

VBA's Round() method rounds a 5 in the last digit to the next EVEN
number (which is pretty standard in scientific and financial
calculations, rather than XL's method that biases results away from
zero). So 0.5 rounds to 0, 1.5 rounds to 2, 2.5 rounds to 2, 3.5 rounds
to 4, etc...

However, you can use XL's function:

Public Sub rwnd()
Dim c As Double
c = 0.5
MsgBox Application.Round(c, 0)
End Sub



In article ,
"rd" wrote:

I wonder why my VBA code is not rounding 0.5 to 1. The code below produces
zero in the message box instead of the required 1.

Public Sub rwnd()
c = 0.5
MsgBox Round(c, 0)
End Sub

Any help would be appreciated.

 
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
ROUNDING FORMULA =ROUND(B12/$B$10,1) ROUNDING TO HIGH SunshineinFt.Myers[_2_] Excel Worksheet Functions 7 March 5th 09 06:41 PM
I need a formula with rounding up & rounding down to the nearest . Tony Kay Excel Worksheet Functions 3 May 29th 07 11:13 PM
Rounding Bud Excel Worksheet Functions 3 November 25th 05 02:33 AM
Rounding El_Melenero Excel Discussion (Misc queries) 0 November 23rd 05 08:06 PM
Worksheet rounding vs VBA rounding Simon Cleal Excel Programming 4 September 2nd 05 01:50 AM


All times are GMT +1. The time now is 06:20 AM.

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

About Us

"It's about Microsoft Excel"