How to use the VBA FIX Function (Syntax + Example)

HomeVBA Functions LIST (Category Wise)How to use the VBA FIX Function (Syntax + Example)

The VBA FIX function is listed under the math category of VBA functions. When you use it in a VBA code, it can truncate a supplied number to an integer. In simple words, it returns an integer in the result after ignoring decimal values from the original number. It’s almost the same as the VBA INT function.

Syntax

Fix(Number)

Arguments

  • Number: The numeric value for which you want to get the integer part.

Example

To practically understand how to use VBA FIX function, you need to go through the below example where we have written a vba code by using it:

Sub example_FIX()
Range("B1").Value = Fix(Range("A1"))  
End Sub

In the above example, we have used the FIX to truncate the number from the cell A1 (-98.12) and it has returned -98 in the cell B1.

Notes

  • If the number supplied contains a NULL then it returns a NULL and if that number is lower than zero then the first negative integer greater than or equal to number is returned.

Related Functions

ABS | ATN | COS | EXP | INT | LOG | RND | ROUND | SGN | SIN | SQR | TAN