Excel ROUND Function
The Excel ROUND function returns a rounded number in accordance with the specified number of digits
Example: Excel ROUND Function
=ROUND(B5,2)
|
Result in cell D5 (5378.73) - returns a number rounded to the right of the decimal point by two.
|
=ROUND(B6,0)
|
Result in cell D6 (5379) - returns a number rounded to the nearest integer.
|
=ROUND(B7,-2)
|
Result in cell D7 (5400) - returns a number rounded to the left of the decimal point by two.
|
=ROUND(B5,C5)
|
Result in cell D5 (5378.73) - returns a number rounded to the right of the decimal point by two.
|
=ROUND(B6,C6)
|
Result in cell D6 (5379) - returns a number rounded to the nearest integer.
|
=ROUND(B7,C7)
|
Result in cell D7 (5400) - returns a number rounded to the left of the decimal point by two.
|
METHOD 3. Excel ROUND function using the Excel built-in function library with hardcoded values
EXCEL
=ROUND(B5,2) Note: in this example we are rounding a number in cell (B5) to the right of the decimal point by two. |
METHOD 4. Excel ROUND function using the Excel built-in function library with links
EXCEL
=ROUND(B5,C5) Note: in this example we are rounding a number in cell (B5) to the right of the decimal point by the amount that is represented by the value cell (C5). |
Dim ws As Worksheet
ws.Range("D5") = Round(ws.Range("B5"), 2)
ws.Range("D6") = Round(ws.Range("B6"), 0)
End Sub
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheet Name: Have a worksheet named ROUND.
Value to Round: Ensure that the value that you want to round is captured in range ("B5:B6").
Output Range: Select the output range by changing the cell references ("D5") and ("D6") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
Value to Round: Select the value that you want to round by changing the range ("B5:B6") to any range in the worksheet, that doesn't conflict with the formula.
ADJUSTABLE NOTES
Negative Rounding Limitation: The VBA ROUND function does not permit the use of a negative number of digits. An alternative method is to use the Application.WorksheetFunction.Round(), which is illustrated in Method 3 and 4.
Dim ws As Worksheet
ws.Range("D5") = Round(ws.Range("B5"), ws.Range("C5"))
ws.Range("D6") = Round(ws.Range("B6"), ws.Range("C6"))
End Sub
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheet Name: Have a worksheet named ROUND.
Value to Round: Ensure that the value that you want to format is captured in range ("B5:B6").
Number of Digits: Ensure that the number of digits to which the specified number should be rounded to is captured in range ("C5:C6").
Output Range: Select the output range by changing the cell references ("D5") and ("D6") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
Value to Round: Select the value that you want to round by changing the range ("B5:B6") to any range in the worksheet, that doesn't conflict with the formula.
Number of Digits: Select the number of digits to which the specified number should be rounded to by changing the range ("C5:C6") to any format that is within Excel's capability.
ADJUSTABLE NOTES
Negative Rounding Limitation: The VBA ROUND function does not permit the use of a negative number of digits. An alternative method is to use the Application.WorksheetFunction.Round(), which is illustrated in Method 3 and 4.
Dim ws As Worksheet
ws.Range("D5") = Application.WorksheetFunction.Round(ws.Range("B5"), 2)
ws.Range("D6") = Application.WorksheetFunction.Round(ws.Range("B6"), 0)
ws.Range("D7") = Application.WorksheetFunction.Round(ws.Range("B7"), -2)
End Sub
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheet Name: Have a worksheet named ROUND.
Value to Round: Ensure that the value that you want to round is captured in range ("B5:B7").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("D5"), ("D6") and ("D7") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
Value to Round: Select the value that you want to round by changing the range ("B5:B7") to any range in the worksheet, that doesn't conflict with the formula.
Dim ws As Worksheet
ws.Range("D5") = Application.WorksheetFunction.Round(ws.Range("B5"), ws.Range("C5"))
ws.Range("D6") = Application.WorksheetFunction.Round(ws.Range("B6"), ws.Range("C6"))
ws.Range("D7") = Application.WorksheetFunction.Round(ws.Range("B7"), ws.Range("C7"))
End Sub
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheet Name: Have a worksheet named ROUND.
Value to Round: Ensure that the value that you want to round is captured in range ("B5:B7").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("D5"), ("D6") and ("D7") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
Value to Round: Select the value that you want to round by changing the range ("B5:B7") to any range in the worksheet, that doesn't conflict with the formula.
Number of Digits: Select the number of digits to which the specified number should be rounded to by changing the range ("C5:C7") to any format that is within Excel's capability.
The Excel ROUND function returns a rounded number in accordance with the specified number of digits.
=ROUND(number, num_digits)
number: (Required) The number that is to be rounded.
num_digits: (Required) The number of digits that the specified number will be rounded to.
ADDITIONAL NOTES
Note 1: The ROUND function can round to the right or left of the decimal point.
Note 2: To round to the right of the decimal point, enter a positive num_digits number.
Note 3: To round to the left of the decimal point, enter a negative num_digits number.
Note 4: Using a 0 as the number_digits number, the ROUND function will round to the nearest integer.