VBA Integer Data Type in Excel

VBA Integer Data Type in Excel

VBA Integer Data Type in Excel explained with syntax and examples. We use the integer VBA data type to store only integer whole numbers. The default value is 0. The integer VBA data type contains range of values between -32,768 to 32,767. Integers cannot have decimal places. The integer number can be positive number, negative number or zero. It is most common frequently used VBA data type. It occupies 2 bytes(16 bits) in memory.

Integer VBA Data Type Syntax in Excel

Let us see the Integer VBA Data Type Syntax in Excel.

Dim VariableName as Integer

Where VariableName represents the name of the variable.
and Integer represents the type of data which contains whole number.

Example on the Integer VBA Data Type in Excel

Here is an example on the Integer Data Type in Excel VBA. In the below example ‘iValue’ is a integer variable and it contains a positive value 800.

Sub VBAF1_Integer_DataType()
    
    'Integer Variable Declaration
    Dim iValue As Integer
    
    'Assign value to integer variable
    iValue = 800
    
End Sub

Example on the Integer VBA Data Type in Excel

Here is an example on the Data Type Integer in Excel VBA.In the below example ‘iValue’ is a integer variable and it contains a negative value – 800.

Sub VBAF1_Integer_DataType()
    
    'Integer Variable Declaration
    Dim iValue As Integer
    
    'Assign value to integer variable
    iValue = -800
    
End Sub

Convert an Expression to Integer VBA Data Type in Excel VBA

You can convert an expression to VBA data type Integer using VBA CInt function. Click on the following link to learn about CInt function and complete tutorial and examples.

VBA CInt Function

Other VBA Data Types

Please click on the following link to read about all other data types.

VBA Data Types

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog

Leave a Comment