Excel Functions Tutorials

- VBA
- VBA Tutorial
- VBA Functions in Excel
- VBA ArrayList
- VBA Arrays Function in Excel
- VBA Activate Sheet
- VBA Break
- VBA Borders
- VBA Boolean
- VBA ByRef
- VBA Code
- VBA Const
- VBA Class Modules
- VBA Count
- VBA COUNTA
- VBA COUNTIF
- VBA Comment Block
- VBA Match Function
- VBA LEFT Function
- VBA Right Function
- VBA Like
- VBA LEN
- VBA Long
- VBA Today
- VBA Now
- VBA Time Function
- VBA Timer
- VBA TimeValue
- VBA Weekday
- VBA ROUND
- VBA RoundUp
- VBA Random Numbers
- VBA ReDIM Function
- VBA Rename Sheet
- VBA Protect Sheet
- VBA Remove Duplicates
- VBA Concatenate
- Copy Paste in VBA
- VBA Paste
- VBA Print
- VBA Date Function
- VBA DateDiff Function
- VBA DateAdd Function
- VBA DatePart
- VBA Data Type
- VBA Dictionary
- VBA Debug Print
- VBA Charts
- VBA CDBL
- VBA CSTR
- VBA Chr
- VBA ChDir
- VBA ENUM
- VBA RegEx
- VBA Mid Function
- VBA Max
- VBA Find Function
- VBA Find and Replace
- VBA Trim Function
- VBA Text
- VBA OFFSET Function
- VBA MOD Function
- VBA Split Function
- VBA UBound Function
- VBA Union
- VBA Transpose
- VBA INT
- VBA InStr
- VBA INSTRREV
- VBA Intersect
- VBA Integer
- VBA DIR Function
- VBA OR Function
- VBA AND
- VBA Operators
- VBA Not Equal
- VBA Worksheet Function
- VBA Workbook
- VBA ThisWorkbook
- VBA Worksheets
- VBA Write Text File
- VBA Hyperlinks
- VBA String Functions
- VBA StrComp
- VBA StrConv
- VBA Sub
- VBA Call Sub
- VBA End
- VBA Wait
- VBA Option Explicit
- VBA SubString
- VBA Subscript Out of Range
- VBA IIF
- VBA IF OR
- VBA IFERROR
- VBA On Error
- VBA OverFlow Error
- VBA 1004 Error
- VBA Error Handling
- VBA Type
- VBA Type Mismatch Error
- VBA IsEmpty
- VBA ISNULL
- VBA Input Box
- VBA MsgBox
- VBA Text Box
- VBA Format
- VBA Format Number
- VBA Conditional Formatting
- VBA AutoFill
- VBA AutoFilter
- VBA Color Index
- VBA Font Color
- VBA Clear Contents
- VBA Collection
- VBA Paste Special
- VBA Progress Bar
- VBA GoTo
- VBA Userform
- VBA Close UserForm
- User Defined Function in Excel VBA
- VBA Outlook
- VBA JOIN
- VBA LCase
- VBA UCase
- VBA Select Case
- VBA Select Cell
- VBA Selection
- VBA Active Cell
- VBA Set
- VBA Sleep
- VBA Pause
- VBA Range Objects
- VBA Range Cells
- VBA UsedRange
- VBA Loop
- VBA Break For Loop
- VBA For Each Loop
- VBA For Next Loop
- VBA Do Until Loop
- VBA File Copy
- VBA FileDialog
- VBA FileSystemObject (FSO)
- VBA Cells
- VBA Last Row
- VBA Insert Row
- VBA Hide Columns
- VBA New Line
- VBA GetOpenFilename
- VBA GetObject
- VBA Delete File
- VBA Delete Row
- VBA Insert Columns
- VBA Delete Column
- VBA Val
- VBA Value
- VBA Variant
- VBA Variable Declaration
- VBA Global Variables
- VBA Pivot Table
- VBA Refresh Pivot Table
- VBA PowerPoint
- VBA Send Email from Excel

- Financial Functions in Excel (17+)
- Logical Functions in Excel (15+)
- TEXT Functions in Excel (29+)
- Lookup Reference in Excel (44+)
- Maths Functions in Excel (52+)
- Date and Time Function in Excel (22+)
- Statistical Function in Excel (50+)
- Information Functions in Excel (5+)
- Excel Charts (48+)
- Excel Tools (98+)
- Excel Tips (178+)

Related Courses

## VBA Round Function

Round function in Excel VBA round up or round down to the specific set of decimal places. For the example of you have the number 5.8697 we can round to two digit decimal three digit decimal or no decimal at all. If you round the number to a two digit decimal it will 5.87 if you round to three digits then it will round to 5.870, if you wish to round to zero then it will 6.

In banking numbers, all the decimal places which are less than 0.5 will be rounded down to the previous integer value and all the decimal places which are greater than or equal to 0.5 will be rounded up to the next integer value.

I hope you have used the ROUND function in the worksheet. In VBA too we can use this function but we have a difference with these functions. We will see the difference between these two functions later in this article.

### Formula

Take a look at the formula of ROUND function in VBA.

**Number: **This is the number we are trying to round.

**[Number of Digits after Decimal]: **How many digits you need after the decimal value.

### Examples of ROUND Function in VBA

Take a look at a few examples to understand the excel VBA ROUND function practically. Assume you have the number 4.534 and you want to round to two digits. Follow the below steps.

**Step 1: **Declare the variable as Variant.

**Code:**

Sub Round_Example1() Dim K As Variant End Sub

**Step 2: **For this variable “**k**” assign the value through VBA ROUND function.

**Code:**

Sub Round_Example1() Dim K As Variant K = Round( End Sub

**Step 3: **Number is nothing but what is the number we are trying to round, in this case, the number is **4.534.**

4.6 (247 ratings)

**Code:**

Sub Round_Example1() Dim K As Variant K = Round(4.534, End Sub

**Step 4: **How many digits we need to round, in this case, we need to round to **2 digits**.

**Code:**

Sub Round_Example1() Dim K As Variant K = Round(4.534, 2) End Sub

**Step 5: **Now show the variable “k” value in the **message box VBA**.

**Code:**

Sub Round_Example1() Dim K As Variant K = Round(4.534, 2) MsgBox K End Sub

Run this code and see what we get.

We got the result as **4.53** when we rounded to 2 digits.

Now I will change the number from **4.534 to 4.535**. Look what happens now.

**Code:**

Sub Round_Example1() Dim K As Variant K = Round(4.535, 2) MsgBox K End Sub

Now run the code and see what the result is.

We got the result as 4.54 one decimal higher than the previous value of 4.53. This is because in this example we have supplied the number as 4.535, so after the number 3 next number is 5 so it is rounded to the next number so 3 becomes 4.

Now I will supply the number as** 2.452678** and I will try to round to 3 digits.

**Code:**

Sub Round_Example2() Dim K As Variant K = Round(2.452678, 3) MsgBox K End Sub

Run this code to see the result.

The result is **2.453**.

2.45**2678 Here** numbers after the 2^{nd} decimal place are 2678. After number 2, the next number is 6 which is greater than or equal to 5 so it is rounded up the next decimal number.

Now I will use the same number to round to zero and see what happens.

**Code:**

Sub Round_Example3() Dim K As Variant K = Round(2.452678, 0) MsgBox K End Sub

Run the code and see what we get.

Since I have used the round to zero we got the result as 2.

The reason why we got the result as 2 because here the decimal first number is 4 which is less than the 0.5 so it is rounded down.

### Differences Between VBA ROUND and Excel ROUND

After all these you must be thinking of what difference between VBA Round and Excel Round is. There are mainly 2 differences.

**#1 – Syntax of Both the Functions: **If you look at the syntax of both the function we have a difference here.

Excel Round Syntax:Round (Number, Number of Digits After Decimal)

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

In Excel VBA ROUND both the arguments are mandatory but in VBA Round second argument is optional.

In VBA if you ignore the second argument VBA takes the default argument as zero so we will get the whole number.

**#2 – Results: **The result given by these two functions are different. Below are a few examples

You can download this VBA Round Function Excel here. VBA Round Function Excel Template

### Recommended Articles

This has been a guide to VBA Round Function. Here we learn how to use Round Function in Excel VBA (up or down) along with some practical examples and downloadable excel template. Below are some useful excel articles related to VBA:-

- VBA Code to Create a Pivot Table
- What is Split in VBA?
- What is VBA?
- Excel VBA End Function
- VBA Call Sub Procedures
- List of VBA Excel Functions
- DIR VBA Function
- Worksheet VBA Function
- MID VBA Function

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