This Excel tutorial explains how to use the Excel CINT function with syntax and examples.
The Microsoft Excel CINT function converts a value to an integer.
The syntax for the CINT function in Microsoft Excel is:
CInt( expression )
The CINT function can be used in the following versions of Microsoft Excel:
The CINT function can be used in Microsoft Excel as the following type of function:
The CINT function can only be used in VBA code in Microsoft Excel.
Let's look at some Excel CINT function examples and explore how to use the CINT function in Excel VBA code:
Dim LValue As Integer LValue = CInt(8.45)
In this example, the variable called LValue would now contain the value of 8.
Be careful using CINT. If you were to use the following code:
Dim LValue As Integer LValue = CInt(8.5)
The variable LValue would still contain the value of 8. Until the fraction is greater than .5, the CINT function will not round the number up.
We've found it useful in the past to add 0.0001 to the value before applying the CINT function to simulate the regular rounding process.
For example, CInt(8.50001) will result in a value of 9.
(scroll to see more)