 # VBA Fix Function

## Overview of VBA Fix Function:

VBA Fix function is categorized as Math(Mathematical) & Trig function. This is a built-in Excel VBA Function. This function returns the integer portion of a number. This function removes the decimals from the argument.

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

### Syntax of VBA Fix Function

The syntax of the Fix Function in VBA is

`Fix(Number)`

The Fix function returns an integer value.

### Parameters or Arguments:

The Fix function has one argument in Excel VBA.
where
Number:The Number is a required parameter. It represents a number or numeric value. We use this parameter for which we want integer portion from a number. The specified number is Null, it returns Null. And the specified number is zero(0), it returns zero(0).

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

We can use this Fix 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: Find an Integer part of the number(4321.8765)

Here is a simple example of the VBA Abs function. This below example find an Integer part of the number(4321.8765).

```'Find an Integer part of the number(4321.8765)
Sub VBA_Fix_Function_Ex1()

'Variable declaration
Dim iValue As Integer
Dim dResult As Double

iValue = 4321.8765

dResult = Fix(iValue)

MsgBox "An Integer part of the number 4321.8765 is : " & dResult, vbInformation, "VBA Fix Function"

End Sub
```

Output: Here is the screen shot of the first example output. ### Example 2: Find an Integer part of the number(-4321.8765)

Here is a simple example of the VBA Abs function. This below example finds an Integer part of the number(-4321.8765).

```'Find an Integer part of the number(-4321.8765)
Sub VBA_Fix_Function_Ex2()

'Variable declaration
Dim iValue As Integer
Dim dResult As Double

iValue = -4321.8765

dResult = Fix(iValue)

MsgBox "An Integer part of the number -4321.8765 is : " & dResult, vbInformation, "VBA Fix Function"

End Sub
```

Output: Here is the screen shot of the second example output. ### Example 3: Find an Integer part of the number(‘4321.8765’)

Here is a simple example of the VBA Abs function. This below example finds an Integer part of the number(‘4321.8765’).

```'Find an Integer part of the number('4321.8765')
Sub VBA_Fix_Function_Ex3()

'Variable declaration
Dim iValue As String
Dim dResult As Double

iValue = "4321.8765"

dResult = Fix(iValue)

MsgBox "An Integer part of the number '4321.8765' is : " & dResult, vbInformation, "VBA Fix Function"

End Sub
```

Output: Here is the screen shot of the third example output. ### Example 4: Find an Integer part of the string(‘Sample_text’)

Here is a simple example of the VBA Abs function. This below examplereturns an error. The input value is not valid.

```'Find an Integer part of the string('Sample_text')
Sub VBA_Fix_Function_Ex4()

'Variable declaration
Dim iValue As String
Dim dResult As Double

iValue = "Sample_text"

dResult = Fix(iValue)

MsgBox "An Integer part of the number 'Sample_text' is : " & dResult, vbInformation, "VBA Fix Function"

End Sub
```

Output: Here is the screen shot of the third example output. ### Instructions to use Macro Codes

Here are the step by step instructions to use the VBA Fix 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.