• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Excel Charts

          • Histogram Chart Excel
          • Basic Excel Formulas
          • Text to Columns in Excel
        • Excel Charts
        • Excel Tips

          • Excel Gantt Chart
          • IFERROR with VLOOKUP
          • Data Table in Excel
        • Excel Tips
        • Excel Tools in Excel

          • Stacked Column Chart
          • Cheat Sheet of Excel Formulas
          • Excel Data Validation
        • Histogram chart in excel
        • Others

          • Resources (A-Z)
          • Excel Functions
          • Financial Functions in Excel
          • Logical Functions in Excel
          • Lookup Reference Functions in Excel
          • Maths Function in Excel
          • TEXT and String Functions in Excel
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Excel Course 1
        • All in One Bundle

          All-in-One-Excel-VBA-Bundle
        • Excel course

          Excel-Training
        • Others

          • Excel advanced course
          • VBA Course
          • Excel Data Analysis Course
          • Excel for Marketing Course
          • Excel for Finance Course
          • View All
  • 120+ Courses All in One Bundle
  • Login

VBA RoundUp

Home » Excel » Blog » VBA » VBA RoundUp

VBA RoundUP

VBA RoundUp Function

In Excel, we have round function which is used to round the numbers up to the decimals we choose. Suppose there is a number which is somewhat like this 8.5036 and we want to roundup it to two numbers. There are actually two methods to do in excel, one is the round button we have in excel as shown in the screenshot below and another is the round function. The screenshot for the round button is as follows.

VBA-ROUNDUP-Increase Decimal

Start Your Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

As explained above, we can round numbers in excel with the option of increase and decrease decimal or round function. Similarly, in VBA we also have round the function which is used to round the numbers to specific decimals. Earlier the round function in excel was using the following arguments.

In Excel: Round (Number, Number of digits after decimal)

The number is the number we want to roundup while the number of digits is the amount of digits we want to round. Similarly, the excel VBA roundup is the same as the excel round function. Have a look at it below.

In VBA: Round (Number, [Number of Digits After Decimal])

The above is the round function in VBA but the roundup function is somewhat different. However, the syntax for round function in VBA and roundup function is similar. It is as follows,

In VBA Roundup is:

Roundup( Number, {Number of digits After Decimal})

RoundUp function is similar to a round function in VBA excel but the difference is that it always roundup the number for the given arguments. Now let us understand the arguments we provide to round function.

We know that number is the number we provide as input which will be round off. The number of digits can be in three scenarios as follows:

Popular Course in this category
Cyber Week Sale
VBA Training (3 Courses, 12+ Projects) 3 Online Courses | 13 Hands-on Projects | 45+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.7 (2,738 ratings)
Course Price

View Course

Related Courses
Excel Advanced Training (14 Courses, 21+ Projects)Excel Data Analysis Training (12 Courses, 6+ Projects)
  • If the number of digits provided is greater than zero then the number is rounded up to the specified decimal place.
  • If the number of digits is provided as input is equal to zero then the number is rounded up to its nearest integer.
  • Now if the number of digits which is provided as input is less than zero then the number is rounded up to the left of its decimal point.

RoundUp function works very similar to the worksheet function of excel. Now keep in mind as it has decimal values to the output it returns in double. It will be clear with a few examples. We will learn all three aspects of roundup function i.e. less than 0, equal to 0 and greater than 0 in examples. For our examples, we will take input from a user and roundup and display it.

How to RoundUp Using VBA?

Let’s see the examples of RoundUp in Excel VBA.

You can download this VBA RoundUp Excel Template here – VBA RoundUp Excel Template

Example #1 – VBA Roundup

Let us begin with the number of digits provided is less than 0 and see how the results pop-up.

Step 1: To begin with VBA we need to be in VB Editor, we can do that by clicking on the developer’s tab and then on Visual basic as shown in the screenshot below,

VBA Roundup (Visual Basic)

Step 2: Now insert a module in the VB Editor where we will begin with VBA Macros, Double Click on the module which will open another window for us where we will write our code,

Excel VBA RoundUP Module

Step 3: Start by a sub-function as follows.

Code:

Sub Sample()

End Sub

VBA RoundUp Example 1.1

Step 4: Declare two variables as double and one as an integer, one which will store the value for input while one will store the value for output and one will store the value for the number of digits we want to roundup,

Code:

Sub Sample()

Dim A, B As Double
Dim C As Integer

End Sub

Example 1.2

Step 5: In variable A store the value of the number which will be rounded up and in C store the value for the number of digits which will be rounded up. Both values we will take as input from a user as follows,

Code:

Sub Sample()

 Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter less than zero")

End Sub

VBA RoundUp Example 1.3

Step 6: In variable B store the rounded up value of A as follows,

Code:

Sub Sample()

Dim A, B As Double
Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter less than zero")
B = Application.WorksheetFunction.RoundUp(A, C)

End Sub

VBA RoundUp Example 1.4

Step 7: Now use msgbox function to display the rounded up value of A as follows,

Code:

Sub Sample()

Dim A, B As Double
Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter less than zero")
B = Application.WorksheetFunction.RoundUp(A, C)
MsgBox B

End Sub

VBA RoundUp Example 1.5

Step 8: Run the above code and give input of A as follows,

Example VBA Output

Step 9: Click on Ok which will give another input box to give the number of digits to be rounded up, give -1 as input,

VBA Example Output 2

Step 10: When we press ok we get the final rounded up result,

Example 1.9

Example #2 – VBA Roundup

In this example, we will take input from the user for a number of digits to be rounded up as 0.

Step 1: Add a new module in the VBA, in the module write another sub-function for another macro as follows,

Code:

Sub Sample1()

End Sub

Example 2.1

Step 2: Again declare three variables, two of them as double while one as an integer as follows,

Code:

Sub Sample1()

Dim A, B As Double
Dim C As Integer

End Sub

Example 2.2

Step 3: We know that A will store the input for the number to be rounded up and B will store the number of digits to be rounded as follows,

Code:

Sub Sample1()

Dim A, B As Double
Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter equal to zero")

End Sub

Example 2.4

Step 4: In variable C we will roundup the input value we took from the user and display it using the msgbox function as follows,

Code:

Sub Sample1()

Dim A, B As Double
Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter equal to zero")
B = Application.WorksheetFunction.RoundUp(A, C)
MsgBox B

End Sub

Example 2.5 (MSGBox)

Step 5: Now run the above code by hitting F5 and give the input for a number to be rounded up as follows,

VBA Example 2 (input 1)

Step 6: Click on Ok and provide the number of digits to be rounded up as 0 as follows,

VBA Example 2 (input 2)

Step 7: When we click on Ok we see the following result,

VBA Roundup Final OutPut

Example #3 – VBA Roundup

Now we will use the final and last option to provide the number of digits to be greater than zero and see the result.

Step 1: Add a new module and in that add a new sub-function as follows,

Code:

Sub Sample2()

End Sub

Example 3.1

Step 2: Now we will again declare three variables, two of them as double and one as an integer. One will store the value for input if the number to be rounded up while another will store the input of a number of digits,

Code:

Sub Sample2()

Dim A, B As Double
Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter greater than zero")

End Sub

Example 3.1

Step 3: In the variable B store the rounded up value of A with roundup function is as follows and use msgbox function to display the result,

Code:

Sub Sample2()

Dim A, B As Double
Dim C As Integer
A = InputBox("Enter a Value", "Value in Decimals")
C = InputBox("Enter number of digits to be rounded up", "Enter greater than zero")
B = Application.WorksheetFunction.RoundUp(A, C)
MsgBox B

End Sub

VBA Roundup Example 3.2

Step 4: Now we run the code and provide the input for the number to be rounded up,

VBA Example

Step 5: Click on Ok and give the number of digits rounded up as 2,

VBA Example 3.5

Step 6: Click Ok to see the final result,

VBA Roundup 3

Things to Remember

There are few things which we need to remember about VBA RoundUp.

  • It is similar to the roundup in VBA and excel.
  • It takes a number of digits as input as less than 0 or greater than 0 or equal to 0.
  • It is actually a worksheet function we use it in VBA.
  • The output returned by this function is double.

Recommended Articles

This is a guide to VBA Roundup. Here we discuss how to use Excel VBA Roundup along with few practical examples and downloadable excel template. You can also go through our other suggested articles –

  1. How to Use VBA While Loop?
  2. VBA Remove Duplicates
  3. Understanding VBA Data Types
  4. VBA Sleep with Examples

All in One Excel VBA Bundle (120+ Courses, 30+ Projects)

120+ Online Courses

30+ Projects

500+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar
Excel Functions Tutorials
  • VBA
    • VBA Max
    • VBA Environ
    • VBA Not
    • VBA LOOKUP
    • Programming in Excel
    • VBA Name Worksheet
    • VBA ScreenUpdating
    • VBA Do Loop
    • VBA Declare Array
    • VBA Macros
    • VBA Delete Sheet
    • VBA Editor
    • VBA Error Handling
    • VBA Goal Seek
    • VBA DateDiff
    • VBA On Error Resume Next
    • VBA Examples
    • VBA Counter
    • VBA Val
    • VBA Me
    • VBA Double
    • VBA Variable Types
    • VBA FreeFile
    • VBA Switch Case
    • VBA Unprotect Sheet
    • VBA Format Number
    • VBA ReDim
    • VBA IF Statements
    • VBA DoEvents
    • VBA Public Variable
    • VBA Columns
    • VBA Cdate
    • VBA Selection Range
    • VBA Hide Columns
    • VBA COUNTA
    • VBA Insert Row
    • VBA Protect Sheet
    • VBA AutoFill
    • VBA IF Not
    • VBA GetObject
    • VBA Debug Print
    • VBA Collection
    • VBA Text
    • VBA Randomize
    • VBA Variant
    • VBA Selection
    • VBA Right
    • VBA Date Format
    • VBA Rename Sheet
    • VBA Paste Values
    • VBA InputBox
    • VBA Conditional Formatting
    • VBA Pause
    • VBA Pivot Table
    • VBA Message Box
    • VBA OFFSET
    • VBA ByRef
    • FileCopy in VBA
    • VBA StrConv
    • VBA SUB
    • VBA Boolean
    • VBA Global Variables
    • VBA Worksheets
    • VBA IIF
    • VBA Close UserForm
    • VBA Variable Declaration
    • VBA Join
    • VBA Dictionary
    • VBA Operators
    • VBA Charts
    • VBA For Each Loop
    • VBA FileDialog
    • VBA Format
    • VBA MID
    • VBA GetOpenFileName
    • VBA DatePart
    • VBA Code
    • VBA Option Explicit
    • VBA FileSystemObject (FSO)
    • VBA ASC
    • VBA UserForm
    • VBA Cells
    • VBA InStrRev
    • VBA Class Module
    • VBA Constants
    • VBA Length of String
    • VBA DateSerial
    • VBA StrComp
    • VBA Array Length
    • VBA Check File Exists
    • VBA Ubound
    • VBA CDBL
    • VBA Activate Sheet
    • VBA DateValue
    • VBA Borders
    • VBA Comment
    • VBA Intersect
    • VBA Workbook
    • VBA Concatenate
    • VBA Name
    • VBA Find and Replace
    • VBA Tutorial
    • VBA CSTR
    • VBA Save As
    • VBA Hyperlink
    • VBA Print
    • VBA Switch
    • VBA END
    • VBA Like
    • VBA Set
    • VBA excel programming
    • VBA Call Sub
    • VBA Object
    • VBA RoundUp
    • VBA ArrayList
    • VBA Named Range
    • VBA PowerPoint
    • VBA Block Comment
    • VBA OverFlow Error
    • VBA Insert Column
    • VBA Lcase
    • VBA List Box
    • VBA Delete File
    • VBA Clear Contents
    • VBA TextBox
    • VBA Font Color
    • VBA Range Cells
    • VBA INT
    • VBA UCASE
    • VBA Value
    • VBA Remove Duplicates
    • VBA Break for Loop
    • VBA Sleep
    • VBA Do Until Loop
    • VBA Union
    • VBA Long
    • VBA Copy Paste
    • VBA Data Types
    • VBA Delete Column
    • VBA Enum
    • VBA IsEmpty
    • VBA 1004 Error
    • VBA RegEx
    • VBA IsNumeric
    • VBA Paste
    • VBA Transpose
    • VBA Left
    • VBA Delete Row
    • VBA Integer
    • VBA Active Cell
    • VBA InStr
    • VBA Round
    • VBA Subscript out of Range
    • VBA Dim
    • VBA Replace
    • VBA Sort
    • VBA String
    • VBA Split
    • VBA Wait
    • VBA MOD
    • VBA Time
    • VBA TIMER
    • VBA While Loop
    • VBA Date
    • Excel VBA MsgBox
    • VBA IFError
    • VBA Color Index
    • VBA Match
    • VBA Case
    • VBA Arrays
    • VBA GoTo
    • VBA On Error
    • VBA Range
    • VBA Do While Loop
    • VBA Number Format
    • VBA Loops
    • VBA TRIM
    • VBA Find
    • VBA Select Case
    • VBA Else If
  • Excel Functions (10+)
  • Excel Tools (97+)
  • Financial Functions in Excel (17+)
  • Logical Functions in Excel (12+)
  • Lookup Reference Functions in Excel (30+)
  • Maths Function in Excel (39+)
  • TEXT and String Functions in Excel (25+)
  • Date and Time Function in Excel (20+)
  • Statistical Functions in Excel (55+)
  • Information Functions in Excel (4+)
  • Excel Charts (44+)
  • Excel Tips (195+)
  • Workplace Productivity (4+)
  • Microsoft Office Tools (14+)
  • Excel Formula and Functions (20+)
  • MS Excel Shortcuts (4+)
Excel Functions Courses
  • VBA Training
  • Excel Advanced Training
  • Excel Data Analysis Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Online Excel Course
  • Free Vba Course
Certification Courses
  • All Courses
  • Excel VBA Course - All in One Bundle
  • VBA Course
  • Excel Data Analysis Course
  • Excel for Marketing Course
  • Excel for Finance Course
  • Excel for HR Training
Resources
  • Resources (A To Z)
  • Excel Charts
  • Excel Tips
  • Excel Tools in Excel
  • Excel Functions
  • Financial Functions in Excel
  • Logical Functions in Excel
  • Lookup Reference Functions in Excel
  • Maths Function in Excel
  • TEXT and String Functions in Excel
  • Date and Time Function in Excel
  • Statistical Functions in Excel
  • Information Functions in Excel
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

Download VBA RoundUp Excel Template

By continuing above step, you agree to our Terms of Use and Privacy Policy.
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect

Limited Period Offer - All in One Excel VBA Bundle (120+ Courses, 500+ hours of Videos) View More

Limited Period Offer - Limited Period Offer - All in One Excel VBA Bundle (120+ Courses, 500+ hours of Videos) View More