Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() "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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() "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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) |