The VBA INT Function

Related Functions:
VBA Fix
VBA Round

Description

The VBA Int function rounds a supplied number down to an integer.

I.e. Positive numbers are rounded towards zero and negative numbers are rounded away from zero.

The syntax of the function is:

Int( Number )

Where the Number argument is the number that you want the integer part of.


VBA Int Function Examples

' Round the numbers 77.7 and -77.7 down to integers
Dim int1 As Integer
Dim int2 As Integer
int1 = Int( 77.7 )
int2 = Int( -77.7 )
' Now, int1 = 77 and int2 = -78

In the above VBA code:


VBA Int Function Error

If the Int function is supplied with a value that cannot be interpreted as a number, it will return the error:

Run-time error '13': Type mismatch

VBA Run Time Error 13 Message Box