Round down a number
To round down a number we need to apply the Excel ROUNDDOWN function
Example: Round down a number
=ROUNDDOWN(B5,C5)
|
The formula uses the Excel ROUNDDOWN function to round down the selected number in cell B5 to the nearest integer.
|
Dim ws As Worksheet
ws.Range("D5") = Application.WorksheetFunction.RoundDown(ws.Range("B5"), ws.Range("C5"))
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 Analysis.
Value to Round: If using the exact VBA code ensure that the value that you want to round down is captured in cell ("B5").
Number of Digits: The value (0) in cell ("C5") represents the number of digits that the selected number should be rounded. 0 represents a rounding to the nearest integer.
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Value to Round: Select the value that you want to round down by changing the cell reference ("B5") in the VBA code to any cell in the worksheet that contains the value that you want to round down and doesn't conflict with the formula.
Number of Digits: You can select the cell that contains the number of digits, which in this example will be 0, by changing the cell reference ("C5") to any cell in the worksheet that contains a value of 0 and doesn't conflict with the formula. You can also hardcode the number of digits directly into the VBA code by replacing ws.Range("C5") with 0.
To round down a number we need to apply the Excel ROUNDDOWN function.
=ROUNDDOWN(number, num_digits)
ARGUMENTS
number: The number that is to be rounded down.
num_digits: The number of digits that the specified number will be rounded down to. In this example we have assigned a value of 0 to num_digits argument, meaning that the value will be rounded down to the nearest integer.