Elite Membership

VBA RoundUp Function

Written by Jeevan A Y Jeevan A Y Freelance Writer Jeevan, a seasoned data expert with 7 years in MIS reporting, excels in Advanced Excel, VBA, Power BI, and SQL. Currently an Assistant Manager MIS, his insightful data storytelling drives swift decision-making. MBA graduate with Finance & Marketing specializations. Published author on 7+ years of experience MBA (Finance & Marketing) Finance View Full Profile
Reviewed by Dheeraj Vaidya, CFA, FRM Dheeraj Vaidya, CFA, FRM Content Reviewer & Course Director Dheeraj is a former J.P. Morgan and CLSA Equity Analyst with nearly two decades of experience in financial modeling, valuation, equity research, and corporate finance. He specializes in helping students and professionals develop practical and in-demand finance skills through structured and AI-powered, 20+ Years of experience CFA, FRM, IIT Delhi, IIM Lucknow Financial Modeling View Full Profile
Updated Dec 23, 2024
Read Time 3 min

Part of our VBA Functions guide · 33 articles →

Excel VBA RoundUp Function

Similar to the Worksheet function, where we round up the numbers to the closest integers, in VBA, we have a RoundUp function which decreases the decimal point for us. The syntax for the RoundUp function is as follows Round up (Number, Number of Digits After Decimal). These two arguments in the function are mandatory.

Download FREE VBA RoundUp Function In Excel Template and Follow Along!
Download Excel Template

When we work with numbers and calculations, we get fraction numbers after the whole number, which is quite common in everyday business. We do not generally bother about the decimal values because it does not impact our result. However, in those situations, we need to round up the numbers to the nearest or immediate whole number. By using the RoundUp function, we can perform this task.

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

VBA RoundUp Function

Before this, recollect the syntax of the RoundUp function.

roundup function

Examples

Let us 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
vba roundup example 1.1
  • When you run the above code, it will convert the provided number, i.e., 288.5264, to the nearest whole number, i.e., 289.
vba roundup example 1.2

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.

Code:

Sub RoundUp_Example2()

    Dim k As Double

    k = WorksheetFunction.RoundUp(288.5264, 1)

    MsgBox k

End Sub
vba roundup example 2.1
  • This code will convert the given number to one decimal point, i.e., 288.6.
vba roundup example 2.2

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
vba roundup example 3.1
  • This code will convert the given number to two decimal points, i.e., 288.53.
vba roundup example 3.2

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
example 4.1
  • This code will convert the given number to three decimal points, i.e., 288.527.
example 4.2

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
example 5.1
  • This code will convert the given number to the nearest ten, i.e., 290.
example 5.2

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
example 6.1
  • This code will convert the number to the nearest hundred, i.e., 300.
example 6.2

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
example 7.1
  • This code will convert the number to the nearest thousand, i.e., 1000.
example 7.2

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

This article has been a guide to VBA RoundUp. Here, we discuss how to use the VBA RoundUp Worksheet function for rounding up the given number based on the given argument with a downloadable Excel template. You can learn more about VBA from the following articles: –

Explore the full VBA Functions guide or browse VBA Resources.