Calculate a math expression into a variable in RunMacro
RunMacro RunnerRunMacro 3.5+
The Calculate command evaluates a math expression (add, subtract, multiply, divide, floor-divide, modulo, exponent) and stores the result in a variable.
Dialog & quick setup

- Add a Variables › Calculate command.
- Set the result variable.
- Enter the expression, using
[var_name]for numeric variables (e.g.[count] + 1). - Save.
Options reference
Modes & when to use
RunMacro Runner
Best for
- Increment/decrement a counter in a loop.
- Compute a sum, difference, or derived value.
- Process numbers before filling a form.
Use an alternative when
- Do not use it for string concatenation or arbitrary Python; use it for supported numeric expressions.
Before you run
- Add Calculate to the macro.
- Prepare the data or target that Calculate will use.
Example workflow
Example: increment a counter each loop
- Declare Variable
count= 0. - In the loop: Calculate
count=[count] + 1. - Use
{count}to show the run count.
Expected result: After execution, Calculate completes the described action and makes its result available to the next step.
Tips & limitations
In expressions, reference variables with
[name] (square brackets), unlike {name} used in text fields.- Variable syntax uses [name]; malformed expressions, missing variables, or division by zero fail.
Applies to RunMacro 3.5+ · RunMacro Runner · Windows 10/11
