1. Round VBA Function – Description
The Round VBA function is used to round numbers with decimal places. How can I use the Round function? In place of the first argument of the function, enter the number you want to round. In place of the second argument, enter the number of decimal places to which you want to round the number. If you want to return a value with no decimal places, do not enter the second argument of the function. The result will be an integer. We can also obtain an integer after using the VBA Fix or VBA Int functions .
2. VBA Round function – Syntax
'OfficeInside.Org Round(Number, [NumDigitsAfterDecimal As Long])
Number : The number we want to round.
NumDigitsAfterDecimal : Optional argument. The number of decimal places to which we want to round the number.
Function return : Numeric value.
3. VBA Round function – Example
How to use Round function in VBA Excel? Below is an example of using the Round function in the VisualBasic Editor.
Example 1 : Rounding a Number Round Function. The result in the MsgBox window and the sheet cell.
'OfficeInside.Org Sub RoundFunctionExample() MsgBox Round(5.123) MsgBox Round(987.123456, 2) Range("A1") = Round(3.141234, 3) MsgBox Round(Range("a1"), 2) End Sub
4. VB Round function – Additional informations
- If we do not enter the second argument of the function, Round returns an integer, so no decimal places
5. Round VisualBasic function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016 , Excel 2019.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions .