# VBA Int Function

## Overview of VBA Int Function:

VBA Int function is categorized as Math(Mathematical) & Trig function. This is a built-in Excel VBA Function. This function rounds a specified number down to its nearest integer. This function returns an integer portion and always returns a double value for valid argument.

We can use this function in Excel and VBA. This function we use in either procedure or function any number of times in a Excel VBA editor window. Let us learn what is the syntax and parameters of the Int function, where we can use this Int Function and real-time examples in Excel VBA.

### Syntax of VBA Int Function

The syntax of the Int Function in VBA is

`Int(Number)`

The Int function returns a double value.

### Parameters or Arguments:

The Int function has one argument in Excel VBA.
where
Number:The Number is a required parameter. This argument represents a number or numeric value. We use this parameter to round down the number to nearest integer. The number is Null, then it returns Null. And the specified number is zero(0), it returns zero(0).

### Where we can apply or use VBA Int Function?

We can use this Int Function in VBA MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.

### Example 1: Round down the number(1234.5) to nearest integer

Here is a simple example of the VBA Abs function. This below example round down the number(1234.5) to nearest integer.

```'Round down the number(1234.5)
Sub VBA_Int_Function_Ex1()

'Variable declaration
Dim iValue As Integer
Dim dResult As Double

iValue = 1234.5

dResult = Int(iValue)

MsgBox "Round down the number(1234.5) is : " & dResult, vbInformation, "VBA Int Function"

End Sub
```

Output: Here is the screen shot of the first example output.

### Example 2: Round down the number(-1234.5) to nearest integer

Here is a simple example of the VBA Abs function. This below example round down the number(-1234.5) to nearest integer.

```'Round down the number(-1234.5)
Sub VBA_Int_Function_Ex2()

'Variable declaration
Dim iValue As Integer
Dim dResult As Double

iValue = -1234.5

dResult = Int(iValue)

MsgBox "Round down the number(-1234.5) is : " & dResult, vbInformation, "VBA Int Function"

End Sub
```

Output: Here is the screen shot of the second example output.

### Example 3: Round down the number(‘1234.5’) to nearest integer

Here is a simple example of the VBA Abs function. This below example round down the number(‘1234.5’) to nearest integer.

```'Round down the number('1234.5')
Sub VBA_Int_Function_Ex3()

'Variable declaration
Dim iValue As String
Dim dResult As Double

iValue = "1234.5"

dResult = Int(iValue)

MsgBox "Round down the number('1234.5') is : " & dResult, vbInformation, "VBA Int Function"

End Sub
```

Output: Here is the screen shot of the third example output.

### Example 4: Round down the number(0.5) to nearest integer

Here is a simple example of the VBA Abs function. This below example Round down the number(0.5) to nearest integer.

```'Round down the number(0.5)
Sub VBA_Int_Function_Ex4()

'Variable declaration
Dim iValue As Integer
Dim dResult As Double

iValue = 0.5

dResult = Int(iValue)

MsgBox "Round down the number(0.5) is : " & dResult, vbInformation, "VBA Int Function"

End Sub
```

Output: Here is the screen shot of the third example output.

### Instructions to use Macro Codes

Let us see the step by step instructions to use the VBA Int function in Excel VBA.

• Open an Excel workbook.
• Press Alt+F11 to open VBA Editor window.
• Go to Insert menu and click on module from the available options.
• Copy above specified macros to the VBA editor.
• Select any procedure from above codes and click on ‘Run’ command or use Keyboard shortcut ‘F5’.

#### List of VBA Functions:

Please click on below link to go back to see all List of VBA Functions.