Excel Guides

Declaring Variables in Excel

There are a few different ways to declare variables in Excel. The most common way is to use the Dim statement. For example:

Dim myVariable As Integer

This would declare a variable called "myVariable" as an integer. You can also use the Dim statement to declare multiple variables at once:

Dim myVariable1 As Integer, myVariable2 As String, myVariable3 As Boolean

Another way to declare variables is to use the Public statement. For example:

Public myVariable As Integer

This would declare a public variable called "myVariable" as an integer. Public variables can be used by any procedure in the workbook. You can also use the Private statement to declare variables that can only be used by the procedure in which they are declared.

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.