Learn Excel - Simplify Life with Excel Concepts

Excel CInt Function (VBA)

CInt Function VBA Code

How to use the CInt Function (VBA)

This Excel tutorial explains how to use the Excel CInt function with syntax and examples using VBA.

SUMMARY:

The Excel VBA CInt function converts an expression into a Integer data type.

For example,

  • The VBA Code CInt(22426.55) would return 22427
  • The VBA Code CInt(33.955555) would return 34

PURPOSE:

To converts a value to an Integer.

RETURN VALUE:

The CInt function returns a Integer value.

SYNTAX:

CInt( expression )

ARGUMENTS:

The CInt function syntax has the following arguments:

  • expression: Required. The expression is that you want to convert to an integer.
    • The "expression" can be any value between -32,768 and 32,767
    • If "expression" is outside the range of the data type being converted to, an error occurs.
    • If "expression" includes any fractions or decimals these are rounded.
      • Any fractional parts less than or equal to 0.5 are rounded down to the nearest even number.
      • Any fractional parts greater than 0.5 are rounded up.

REMARKS:

  • The CInt function can only be used in VBA code in Microsoft Excel.
  • The Integer data type is a Value data type.
  • The Integer data type can hold integer values between -32,768 and 32,767
  • VBAs hexadecimal notation symbol is "&H"

Useful Links: Link 1Link 2Link 3Link 4