VBA INT Function (Syntax + Example)

Last Updated: October 29, 2023
puneet-gogia-excel-champs

- Written by Puneet

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.

Syntax

Int(Number)

Arguments

  • Number: The numeric value from which you want the integer part.

Example

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:

example-vba-int-function
Sub example_INT()
Range("B1").Value = Int(Range("A1"))
End Sub

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.

Notes

  • 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.