Dim VBA – Declare Variable

Associated Files Download Links

The Dim Keyword in VBA

You can use the Dim keyword in order to declare a variable in VBA:

Dim stands for Dimension. When you use the Dim keyword, state the name and data type of the new variable.

This is shown in the code below:

We have declared five different variables in the above code, and used five different data types. You can learn more about how to name variables and variable data types in our VBA Data Types – Variables and Constants tutorial where we go into detail about what variables are, how to name them and the different data types available in VBA.

You may also like some of this related content...

We covered arrays, static arrays and dynamic arrays in a previous tutorial.  We are going
A VBA Static variable retains its value even when the procedure ends. Declaring a Static
We covered an introduction to variables and constants in our VBA Data Types – Variables and
We have already covered an introduction to variables, constants and VBA data types in an
We are going to cover Global Variables, in this tutorial. A variable in VBA can