Round
Returns a number rounded to a specified number of decimal places.
Syntax: Round( expression [ , numdecimalplaces ] )
- expression
- required Numeric expression being rounded.
- numdecimalplaces
- optional Number indicating how many places to the right of the decimal are included in the rounding. If omitted, integers are returned by the Round function.
Note
Round uses banker’s rounding (round half to even): when the value is exactly half-way between two possible rounded results, it rounds toward the nearest even digit. For example, Round(0.5, 0) returns 0, and Round(1.5, 0) returns 2.
Note
Round(-0.5) returns negative zero, which equals 0. A 32-bit build prints it as 0, as VB6 does, and a 64-bit build as -0, as 64-bit VBA does. See Double.
Common Errors
| Error | When |
|---|---|
5 (&H5), Invalid procedure call or argument | numdecimalplaces rounds to a negative number numdecimalplaces is greater than 22 and expression is a Single, Double or Date, or a string |
94 (&H5E), Invalid use of Null | numdecimalplaces is Null |
Example
Debug.Print Round(0.12335, 4) ' 0.1234
Debug.Print Round(0.12345, 4) ' 0.1234
Debug.Print Round(0.12355, 4) ' 0.1236
Debug.Print Round(0.12365, 4) ' 0.1236
Debug.Print Round(0.00005, 4) ' 0