Starbucks_33
Active Member
- Joined
- Jun 16, 2008
- Messages
- 345
Hi,
I was using the "round" functionin VBA and realized that it does not work, because it uses the "Bankers" method of rounding, whereas I want the "Arithmatic" rounding, I looked through the web and went to:
http://support.microsoft.com/kb/196652
But the problem is the function is not working.
<A href="http://support.microsoft.com/kb/196652">
I put in AsymArith(8010.095,2) and it gives me 8011.
I also tried this function:
myRound(8010.095,2) gives 8010.09
I cant get rid of the underlines. A
Also I don't want to use Application.round because this will slow down my code too much
Thanks
I was using the "round" functionin VBA and realized that it does not work, because it uses the "Bankers" method of rounding, whereas I want the "Arithmatic" rounding, I looked through the web and went to:
http://support.microsoft.com/kb/196652
But the problem is the function is not working.
<A href="http://support.microsoft.com/kb/196652">
HTML:
Function AsymArith(ByVal X As Double, _
Optional ByVal Factor As Double = 1) As Double
AsymArith = Int(X * Factor + 0.5) / Factor
End Function
I put in AsymArith(8010.095,2) and it gives me 8011.
I also tried this function:
HTML:
Function myRound(num, Optional places As Long = 0)
If Int(num) Mod 2 = 0 Then
myRound = Round(num + 1 / (10 ^ places), places) - 1 / (10 ^ places)
Else
myRound = Round(num, places)
End If
End Function
myRound(8010.095,2) gives 8010.09
I cant get rid of the underlines. A
Also I don't want to use Application.round because this will slow down my code too much
Thanks
Last edited: