Similar to the worksheet function where we round up the numbers to the closest integers, in VBA we have a round-up function which decrease the decimal point for us and the syntax to use the roundup function in VBA is as follows Round up ( Number, Number of Digits After Decimal) these two arguments in the function are mandatory.

## RoundUp Function in VBA Excel

When we work with numbers and calculations we get fractions numbers after the whole number and it is quite common in everyday business. We don’t generally bother about the decimal values because it doesn’t make any impact on our end result. In those situations, we need to round up the numbers to the nearest whole number or immediate whole number. By using the RoundUp function we can actually perform this task. In this article, we will show you an excel VBA RoundUp function.

If you have searched in VBA for RoundUp function then you must have not found it because RoundUp is not a VBA function rather it is a worksheet function. In order to access the RoundUp function in VBA, we need to use Worksheet Function class.

Before this recollect the syntax of the RoundUp function.

### Examples of RoundUp Function in VBA Excel

Below are the examples of RoundUp Function in Excel VBA.

Let’s perform the task of rounding up the number “288.5264”. We will see all the numbers with this example.

#### Example #1 – When the Second Argument is Zero

Look at the below VBA code.

**Code:**

Sub RoundUp_Example1() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, 0) MsgBox k End Sub

When you will run the above code it will convert the provided number i.e. 288.5264 to the nearest whole number i.e. 289.

#### Example #2 – When the Second Argument is 1

Look at the below code to see what happens when we pass one as a second argument.

4.6 (247 ratings)

**Code:**

Sub RoundUp_Example2() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, 1) MsgBox k End Sub

This code will convert the given number to one decimal point i.e. 288.6

#### Example #3 – When the Second Argument is 2

Look at the below code to see what happens when we pass two as a second argument.

**Code:**

Sub RoundUp_Example3() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, 2) MsgBox k End Sub

This code will convert the given number to two decimal points i.e. 288.53

#### Example #4 – When the Second Argument is 3

Look at the below code to see what happens when we pass three as a second argument.

**Code:**

Sub RoundUp_Example4() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, 3) MsgBox k End Sub

This code will convert the given number to three decimal points i.e. 288.527

#### Example #5 – When the Second Argument is -1

Look at the below code to see what happens when we pass minus one as a second argument.

**Code:**

Sub RoundUp_Example5() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, -1) MsgBox k End Sub

This code will convert the given number to nearest ten i.e. 290.

#### Example #6 – When the Second Argument is -2

Look at the below code to see what happens when we pass minus two as a second argument.

**Code:**

Sub RoundUp_Example6() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, -2) MsgBox k End Sub

This code will convert the given number to nearest hundred i.e. 300.

#### Example #7 – When the Second Argument is -3

Look at the below code to see what happens when we pass minus three as a second argument.

**Code:**

Sub RoundUp_Example7() Dim k As Double k = WorksheetFunction.RoundUp(288.5264, -3) MsgBox k End Sub

This code will convert the number to nearest thousand i.e. 1000.

Like this, we can use the ROUNDUP function in VBA as part of the worksheet function class to rounding up the numbers based on the provided second argument.

### Recommended Articles

This has been a guide to VBA RoundUp Function. Here we discuss how to use VBA RoundUp worksheet function in excel for rounding up the given number based on the given argument. You can learn more about VBA from the following articles –

- Rename Sheet using VBA Code
- Examples of VBA Wait Function
- TimeValue Function in VBA
- VBA DatePart Function
- Count Numerical Values in VBA
- Integer Data Type in Excel VBA
- ISNULL Function in VBA
- Boolean Datatype in VBA

- 3 Courses
- 12 Hands-on Projects
- 43+ Hours
- Full Lifetime Access
- Certificate of Completion