ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fundamental use of Round (https://www.excelbanter.com/excel-programming/292552-fundamental-use-round.html)

Stuart[_5_]

Fundamental use of Round
 
In the calculation:
C.Offset(0, 3).Value = qty * rate

how may I ensure that calculated value is to 2 decimal places?

That is to say, if the computed value was 10.494 then it would
Round to 10.49, but if it were 10.495, then it would Round to
10.50.

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004



Frank Kabel

Fundamental use of Round
 
Hi Stuart
try
C.Offset(0, 3).Value = Round(qty * rate,2)

--
Regards
Frank Kabel
Frankfurt, Germany

Stuart wrote:
In the calculation:
C.Offset(0, 3).Value = qty * rate

how may I ensure that calculated value is to 2 decimal places?

That is to say, if the computed value was 10.494 then it would
Round to 10.49, but if it were 10.495, then it would Round to
10.50.

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004


Stuart[_5_]

Fundamental use of Round
 
Just fine!

Many thanks and Regards.

"Frank Kabel" wrote in message
...
Hi Stuart
try
C.Offset(0, 3).Value = Round(qty * rate,2)

--
Regards
Frank Kabel
Frankfurt, Germany

Stuart wrote:
In the calculation:
C.Offset(0, 3).Value = qty * rate

how may I ensure that calculated value is to 2 decimal places?

That is to say, if the computed value was 10.494 then it would
Round to 10.49, but if it were 10.495, then it would Round to
10.50.

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004



JE McGimpsey

Fundamental use of Round
 
Just a caveat: Round() is a VBA6 introduction, so won't work with XL97
or MacXL.

Also, remember that VBA's Round uses what MS calls "Banker's Rounding"
in which numbers ending with the digit 5 are rounded to the nearest
*even* number. This is different than XL's Symmetric Arithmetic ROUND
which always rounds away from zero:


Bankers: Round(4.495, 2) == 4.50
Round(4.485, 2) == 4.48

XL's: ROUND(4.495, 2) == 4.50
ROUND(4.485, 2) == 4.49

There are dozens of ways to round numbers. See

http://support.microsoft.com/default...b;en-us;196652

for a fair discussion with VBA algorithms...

In article ,
"Frank Kabel" wrote:

Hi Stuart
try
C.Offset(0, 3).Value = Round(qty * rate,2)


Stuart[_5_]

Fundamental use of Round
 
Many thanks.

This could be a problem?

I have '97 and '2000 Excel users working with an addin
developed under Excel2000, and we need a solution
which will always give XL's Symmetric Arithmetic ROUND.

Can I achieve this, please?

Background:
Prior to this, the users' data has almost always had qty as an Integer
and always rate as a value with 2 decimal places.
This seems to be changing, such that qty is increasingly becoming a
non-Integer value, and since the results of each individual calculation
are Summed...............

The requirement is that each calculation is 'Rounded' at source,
rather than 'Round' the summed value, if that makes sense.

Regards and thanks.


"JE McGimpsey" wrote in message
...
Just a caveat: Round() is a VBA6 introduction, so won't work with XL97
or MacXL.

Also, remember that VBA's Round uses what MS calls "Banker's Rounding"
in which numbers ending with the digit 5 are rounded to the nearest
*even* number. This is different than XL's Symmetric Arithmetic ROUND
which always rounds away from zero:


Bankers: Round(4.495, 2) == 4.50
Round(4.485, 2) == 4.48

XL's: ROUND(4.495, 2) == 4.50
ROUND(4.485, 2) == 4.49

There are dozens of ways to round numbers. See

http://support.microsoft.com/default...b;en-us;196652

for a fair discussion with VBA algorithms...

In article ,
"Frank Kabel" wrote:

Hi Stuart
try
C.Offset(0, 3).Value = Round(qty * rate,2)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004



JE McGimpsey

Fundamental use of Round
 
Take a look at the MSKB article I cited - there's a VBA5 routine for
Symmetric Arithmetic Rounding there - put that in your code and call it
instead of VBA's round.


In article ,
"Stuart" wrote:

Many thanks.

This could be a problem?

I have '97 and '2000 Excel users working with an addin
developed under Excel2000, and we need a solution
which will always give XL's Symmetric Arithmetic ROUND.

Can I achieve this, please?


Stuart[_5_]

Fundamental use of Round
 
Many thanks and Regards...again.

"JE McGimpsey" wrote in message
...
Take a look at the MSKB article I cited - there's a VBA5 routine for
Symmetric Arithmetic Rounding there - put that in your code and call it
instead of VBA's round.


In article ,
"Stuart" wrote:

Many thanks.

This could be a problem?

I have '97 and '2000 Excel users working with an addin
developed under Excel2000, and we need a solution
which will always give XL's Symmetric Arithmetic ROUND.

Can I achieve this, please?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004




All times are GMT +1. The time now is 12:28 PM.

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