INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Microsoft: Access Other topics FAQ

VBA and Custom Functions

 Rounding functions by Craig0201 faq181-1317 Posted: 4 Dec 01 A pair of rounding functions.  Work identically to those in Excel.Function Round(Number As Double, Num_Digits As Integer) As Double'Set up variablesDim dblNumNum_Digits As DoubleDim intNumNum_Digits As Integer'Move decimal point such that int will perform at correct leveldblNumNum_Digits = Number * (10 ^ Num_Digits)'IntegeriseintNumNum_Digits = Int(dblNumNum_Digits)'Compare integer to see if needs rounding upIf dblNumNum_Digits - intNumNum_Digits >= 0.5 Then    'round up    intNumNum_Digits = intNumNum_Digits + 1Else    'round down    intNumNum_Digits = intNumNum_DigitsEnd If'Return result, moving decimal point backRound = intNumNum_Digits / (10 ^ Num_Digits)End FunctionFunction MRound(Number As Double, Multiple As Double) As Double'Set up variablesDim dblDivided As DoubleDim dblIntDivided As Double'DividedblDivided = Number / Multiple'IntegerisedblIntDivided = Int(dblDivided)'Round dblDivided to nearest whole number in intDivideddblIntDivided = dblIntDivided + Round(dblDivided - dblIntDivided, 0)'Return result, returning to nearest multipleMRound = dblIntDivided * MultipleEnd FunctionHope they help!Craig Back to Microsoft: Access Other topics FAQ Index Back to Microsoft: Access Other topics Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!