VBA Data Types
The computer cannot differentiate between the numbers (1, 2, 3,...) and strings (a, b, c,...). To make this differentiation, we use the Data Types.
The data type you assign to a variable will be dependent on the type of data you want that variable to hold.
In VBA, there are many data types. We divide the data types into two main categories, namely numeric and non-numeric data types.
Below is the table that shows all the available data types you can use in VBA Excel.
Numeric Data Types
Non-Numeric Data Types
Note: if the data type is not specified, it will atomically declare the variable as a variant in VBA.
When you specify the data type of a variable in code, it tells VBA to how to store the variable, and how much space has to allocate for it.
For example, if you need to use a variable is meant to hold the month number, you can use the Byte data type (which accommodate values from 0 to 255). Since the month number is not going to be above 12, this will work fine and also reserve less memory for this variable.
And, if you need a variable to store the row numbers in Excel, you need to use a data type that can accommodate a number up to 1048756. So it's good to use the Long data type