VBA INT Function

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

What is VBA INT Function

how to use it

To use VBA's INT function you need to understand its syntax and arguments:

Syntax

Int(Number)

Arguments

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

Example to use INT Function in VBA

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

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 the cell A1 and return the result in the cell B1. And when we run the code it has returned the 13 in the cell B1.

Notes

Below are some important points which you need to take care while using INT function in VBA.

  • 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 towards zero and if the supplied number is negative then away from zero.

Related Functions

About the Author

puneet one point one

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 find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.