Variables with local scope, also known as local variables, are declared using either the Dim or Local keywords.
Local x As Number 'equivalent to Dim x As Number
Local variables are restricted to a single formula and a single evaluation of that formula. This means that you cannot access the value of a local variable in one formula from a different formula.
Example
Rem Formula A Local x as Number x = 10 formula = x Rem Formula B EvaluateAfter ({@Formula A}) Local x as Number formula = x + 1
The function call EvaluateAfter ({@Formula A}) ensures that Formula B will be evaluated after Formula A is evaluated. Formula A returns a value of 10 and Formula B returns a value of 1. Formula B does not have access to Formula A's x and thus cannot use the value of 10 and add 1; instead, it uses the default value for the uninitialized local variable x found in Formula B, which is 0, and adds 1 to it to get 1.
You can also create local variables with the same name but different types in different formulas. For example, the type declarations in formulas A and B do not conflict with:
Rem Formula C Local x as String x = "hello" formula = x
Local variables are the most efficient of the three scopes. In addition, they do not interfere with one another in different formulas. For these reasons, it is best to declare variables to be local whenever possible.