Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Can anyone help Me for this Problem

Please go through the following excel Macro

Sub Arvind()
a = 1.845
b = Round(a, 2)
End Sub


i want "b" value as 1.85 but the macro is giving me 1.84.
What can i do for this ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 364
Default Can anyone help Me for this Problem

Following is taken from http://www.techonthenet.com/excel/formulas/round.php

In Excel's VBA environment, the Round function returns a number rounded to a
specified number of decimal places. However, the Round function behaves a
little peculiar, so before using this function, please read the following:

The Round function utilizes round-to-even logic. If the expression that you
are rounding ends with a 5, the Round function will round the expression so
that the last digit is an even number. For example:

Round(12.55, 1) would return 12.6 (rounds up)
Round(12.65, 1) would return 12.6 (rounds down)
Round(12.75, 1) would return 12.8 (rounds up)

In these cases, the last digit after rounding is always an even number. So,
be sure to only use the Round function if this is your desired result.

Acknowledgements: A special thanks to Mary S.

"Arvind Mane" wrote:

Please go through the following excel Macro

Sub Arvind()
a = 1.845
b = Round(a, 2)
End Sub


i want "b" value as 1.85 but the macro is giving me 1.84.
What can i do for this ?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default Can anyone help Me for this Problem

i want "b" value as 1.85 but the macro is giving me 1.84.

What can i do for this ?


Hi. I believe the vba version uses the Round-to-even method
http://en.wikipedia.org/wiki/Rounding

Seems like the help system in Excel 2007 dropped some of this information.

Sub Arvind()
Dim a, b
a = 1.845
b = Round(a, 2)
b = WorksheetFunction.Round(a, 2)
End Sub

--
Dana DeLouis


"Arvind Mane" wrote in message ...

Please go through the following excel Macro

Sub Arvind()
a = 1.845
b = Round(a, 2)
End Sub


i want "b" value as 1.85 but the macro is giving me 1.84.
What can i do for this ?
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Can anyone help Me for this Problem


"Arvind Mane" wrote in message
...
Please go through the following excel Macro

Sub Arvind()
a = 1.845
b = Round(a, 2)
End Sub


i want "b" value as 1.85 but the macro is giving me 1.84.
What can i do for this ?


"Arvind Mane" wrote in message
...
Please go through the following excel Macro

Sub Arvind()
a = 1.845
b = Round(a, 2)
End Sub


i want "b" value as 1.85 but the macro is giving me 1.84.
What can i do for this ?


If you'r only ever woorking with 3 decimal places, you could try :-

Sub Arvind()
a = 1.845
b = Round(a - 0.0001, 2)
End Sub

--
Rich
http://www.richdavies.com/excel.htm
http://www.richdavies.com/mp3-downloads.htm





** Posted from http://www.teranews.com **
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Can anyone help Me for this Problem


"Arvind Mane" wrote in message
...
Please go through the following excel Macro

Sub Arvind()
a = 1.845
b = Round(a, 2)
End Sub


i want "b" value as 1.85 but the macro is giving me 1.84.
What can i do for this ?



If you'r only ever working with 3 decimal places, you could try :-

Sub Arvind()
a = 1.845
b = Round(a - 0.0001, 2)
End Sub

--
Rich
http://www.richdavies.com/excel.htm
http://www.richdavies.com/mp3-downloads.htm





** Posted from http://www.teranews.com **
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
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM


All times are GMT +1. The time now is 02:26 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"