ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rounding up decimals (https://www.excelbanter.com/excel-programming/304167-rounding-up-decimals.html)

Michael Malinsky[_3_]

Rounding up decimals
 
Assuming your value is stored in variable num:

Format(num, "#,##0.00")

Will put it in comma format.

HTH
Mike
--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh

"MAS" wrote in message
...
Hi,

I have a msgbox that displays the result of some work , for example as
28.58333

How do i get the result to display just 2 decimal places, ie 28.58

M






MAS

Rounding up decimals
 
Hi,

I have a msgbox that displays the result of some work , for example as
28.58333

How do i get the result to display just 2 decimal places, ie 28.58

M




MAS

Rounding up decimals
 
Thanks Mike

Had been scratching my head on that one..

MAS

"Michael Malinsky" wrote in message
...
Assuming your value is stored in variable num:

Format(num, "#,##0.00")

Will put it in comma format.

HTH
Mike
--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh

"MAS" wrote in message
...
Hi,

I have a msgbox that displays the result of some work , for example as
28.58333

How do i get the result to display just 2 decimal places, ie 28.58

M








Jerry W. Lewis

Rounding up decimals
 
You can also call the worksheet round function as in
Application.Round(num, 2)
or if you have Excel 2000 or later, VBA has its own Round function.

Jerry

MAS wrote:

Thanks Mike

Had been scratching my head on that one..

MAS

"Michael Malinsky" wrote in message
...

Assuming your value is stored in variable num:

Format(num, "#,##0.00")

Will put it in comma format.

HTH
Mike
--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh

"MAS" wrote in message
...

Hi,

I have a msgbox that displays the result of some work , for example as
28.58333

How do i get the result to display just 2 decimal places, ie 28.58

M









Myrna Larson

Rounding up decimals
 
Just a caveat: the two functions (as I'm sure Jerry knows) give different
results when the digit to be rounded equals 5. Here's an example:

? round(2.5,0), application.round(2.5,0)

The above prints 2 and 3 as the results.


On Fri, 16 Jul 2004 02:33:51 GMT, "Jerry W. Lewis"
wrote:

You can also call the worksheet round function as in
Application.Round(num, 2)
or if you have Excel 2000 or later, VBA has its own Round function.

Jerry

MAS wrote:

Thanks Mike

Had been scratching my head on that one..

MAS

"Michael Malinsky" wrote in message
...

Assuming your value is stored in variable num:

Format(num, "#,##0.00")

Will put it in comma format.

HTH
Mike
--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh

"MAS" wrote in message
...

Hi,

I have a msgbox that displays the result of some work , for example as
28.58333

How do i get the result to display just 2 decimal places, ie 28.58

M









Jerry W. Lewis

Rounding up decimals
 
Specifically, the VBA round function follows the rounding rules
specified by ASTM and many other standards bodies: by rounding to the
nearest rounded number, with ties (exactly 5) rounding up or down as
necessary to leave the last rounded digit even. The worksheet round
function uses the simplified rule that many people are more familiar
with: where ties always round up.

Jerry

Myrna Larson wrote:

Just a caveat: the two functions (as I'm sure Jerry knows) give different
results when the digit to be rounded equals 5. Here's an example:

? round(2.5,0), application.round(2.5,0)

The above prints 2 and 3 as the results.


On Fri, 16 Jul 2004 02:33:51 GMT, "Jerry W. Lewis"
wrote:


You can also call the worksheet round function as in
Application.Round(num, 2)
or if you have Excel 2000 or later, VBA has its own Round function.

Jerry

MAS wrote:


Thanks Mike

Had been scratching my head on that one..

MAS

"Michael Malinsky" wrote in message
...


Assuming your value is stored in variable num:

Format(num, "#,##0.00")

Will put it in comma format.

HTH
Mike
--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh

"MAS" wrote in message
...


Hi,

I have a msgbox that displays the result of some work , for example as
28.58333

How do i get the result to display just 2 decimal places, ie 28.58

M










All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com