What is VBA FIX Function
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.
how to use it
To use VBA's FIX function you need to understand its syntax and arguments:
- Number: The numeric value for which you want to get the integer part.
Example to use FIX Function in VBA
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.
Below are some important points which you need to take care while using FIX function in VBA.
- 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.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.