Round a number to two decimal places
This tutorial shows how to round a number to two decimal places through the use of Excel or VBA
Example: Round a number to two decimal places
=ROUND(B5,C5)
|
This formula uses the Excel ROUND function to round the selected number in cell B5 to two decimal places by using the value of 2 as the num_digit.
|
Sub Round_to_two_decimal_places()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'round a number to two decimal places
ws.Range("D5") = Application.WorksheetFunction.Round(ws.Range("B5"), ws.Range("C5"))
ws.Range("D5") = Application.WorksheetFunction.Round(ws.Range("B5"), ws.Range("C5"))
End Sub
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code.
Number to Round: Select the number that you want to round to two decimal places by changing the cell reference ("B5"), in the VBA code, to the cell that captures the number. Alternatively, you can change the number in cell ("B5") to the number that you want to round to two decimal places.
Worksheet Selection: Select the worksheet which captures the number that you want to round to two decimal places by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code.
Number to Round: Select the number that you want to round to two decimal places by changing the cell reference ("B5"), in the VBA code, to the cell that captures the number. Alternatively, you can change the number in cell ("B5") to the number that you want to round to two decimal places.
Worksheet Selection: Select the worksheet which captures the number that you want to round to two decimal places by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.
EXPLANATION
This tutorial shows how to round a number to two decimal places through the use of Excel or VBA.
This tutorial shows how to round a number to two decimal places through the use of Excel or VBA.
FORMULAS
=ROUND(number, 2)
=ROUND(number, 2)
ARGUMENTS
number: The number that is to be rounded to two decimal places.
number: The number that is to be rounded to two decimal places.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Round to the nearest thousand | How to round to the nearest thousand using Excel and VBA | |
Round to the nearest million | How to round to the nearest million using Excel and VBA | |
Round up a number | How to round up a number using Excel and VBA | |
Round down a number | How to round down a number using Excel and VBA | |
Round a number | How to round a number to the nearest integer using Excel and VBA |
RELATED FUNCTIONS
Related Functions | Description | Related Functions and Description |
---|---|---|
ROUND Function | The Excel ROUND function returns a rounded number in accordance with the specified number of digits |