The VBA INT function is listed under the math category of VBA functions. When you use it in a VBA code, it can round down a number to an integer. In simple words, it rounds a positive number toward zero and a negative number away from zero. It simply works like the INT function in the worksheet.
- Number: The numeric value from which you want the integer part.
To practically understand how to use the VBA INT function, you need to go through the below example where we have written a vba code by using it:
Range("B1").Value = Int(Range("A1"))
In the above code, we have used INT to get the integer part from the value (13.54) that we have in cell A1 and return the result in cell B1. And when we run the code it returned the 13 in cell B1.
- If the value specified is a value other than a number or a string that can’t be recognized as a number, VBA will return the run-time 13 error.
- If the supplied number is positive then it rounds that number toward zero and if the supplied number is negative then away from zero.