Round to the nearest million

To round a number to the nearest million we need to apply the Excel ROUND function

Example: Round to the nearest million

Round to the nearest million

METHOD 1. Round to the nearest million

EXCEL

=ROUND(B5,C5)
The formula uses the Excel ROUND function to round the selected number in cell B5 to the nearest million by using the -6 as the num_digit.

METHOD 1. Round to the nearest million using VBA

VBA

Sub Round_to_the_nearest_million()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to round to the nearest million
ws.Range("D5") = Application.WorksheetFunction.Round(ws.Range("B5"), ws.Range("C5"))

End Sub

OBJECTS
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.
PREREQUISITES
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 to the nearest million is captured in cell ("B5").
Number of Digits: The value (-6) in cell ("C5") represents the number of digits that the selected number should be rounded. -6 represents a rounding to the nearest million.

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 to the nearest million 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 to the nearest million 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 -6, by changing the cell reference ("C5") to any cell in the worksheet that contains a value of -6 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 -6.

Explanation about the formula used to round to the nearest million

EXPLANATION

EXPLANATION
To round a number to the nearest million we need to apply the Excel ROUND function.
FORMULAS
=ROUND(number, -6)

ARGUMENTS
number: The number that is to be rounded to the nearest million.