Rounding Up Question

amerfeld

Registered User.
Local time
Today, 09:37
Joined
Aug 17, 2004
Messages
58
Haven't been able to find an answer to this one. I have a currency field that I need to round and display the result in another field. What I am having trouble with is: I need to round up anytime there is anything other than a zero in the thousandth place. For example: .331 would round to .34. How can this be done?

Any help appreciated as always!
 
amerfeld,

Either return the number if the third decimal place is "0", or add
.01 to the truncated xxx.xx number.

Indented for readability:

Code:
IIf (Mid(Format(Test, "00000.000"), 9, 1) = "0", 
     Test, 
     CDbl(Mid(Format(Test, "00000.00"), 1, 9) + 0.01))

Wayne
 
try as well this solution:

Code:
Function roundNumber(numb As Double, Optional decim As Integer = 2)
  exp_dec = 10 ^ decim
  numb = numb * exp_dec
  roundNumber = (Int(numb) + Abs(numb > Int(numb))) / exp_dec
End Function

HTH

filo65
 
Thanks!

Thanks so much. Was able to get Filo65's code to work. :cool:
 

Users who are viewing this thread

Back
Top Bottom