Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function Round(Value As Double, _
Optional NumDecimals As Integer = 0) _
As Double
' Rounds Value to NumDecimals places. For example, if
' NumDecimals = 1, 1234.567 would be rounded to 1234.6.
' Rounding is to lower value when next digit is 0 to 4,
' to higher value when next digit is 5 to 9.
' If NumDecimals is negative, an 'Invalid Procedure Call
' or Argument' error occurs.
Dim factor As Long, temp As Long
If NumDecimals < 0 Then Err.Raise 5
factor = 10 ^ NumDecimals
temp = Fix(Value * factor + 0.5)
' For "banker's rounding" change the above to:
' temp = CLng(Value * factor)
Round = temp / factor
End Function