Variables and types

A VBA variable is a named location in memory that stores a value of a given type: Integer, Long, Double, String, Boolean, Date, Variant. It is declared with Dim, and Option Explicit forces this declaration to avoid typos. Choosing the right type limits errors and saves memory.

Example

Dim total As Double total = Range("B2").Value * 1.2

Related concepts

The whole glossary