About Formulas

Office 2013 and later

Last modified: January 04, 2012

Applies to: Office 2013 | Visio 2013

In this article
Elements of a formula
Default formulas
Inherited formulas
Local formulas
Automatic updates to formulas

The key to controlling shape actions is to write formulas that define the behavior you want. You can edit a cell's formula to change the value of the cell and, as a result, change a particular shape's behavior. For example, the Height cell in the Shape Transform section contains a formula that you can change to alter the shape's height.

Microsoft Visio formulas are similar to typical spreadsheet formulas in many ways. Visio regards anything in a cell, even if it is a numeric value or simple cell reference, as a formula.

A formula in a cell can be inherited from the equivalent cell of a master or a style or defined locally. Visio evaluates the formula and then converts the results to an appropriate value and appropriate units for the cell. In a ShapeSheet window, you can display cell contents as either formulas or values.

A formula always starts with an equal sign, which is inserted automatically. A formula can include any of the following elements:

  • Numbers

  • Coordinates

  • Boolean values

  • Operators

  • Functions

  • Strings

  • Cell references

  • Units of measure

When you create a shape, Visio creates formulas for it by default. To see what the default formulas are, draw a simple shape (such as a rectangle, ellipse, or straight line) and open its ShapeSheet window (on the Developer tab, click Show ShapeSheet).

Visio inherits formulas whenever possible. Rather than make a local copy of every formula in the instance, an instance inherits formulas from its master on the document stencil and inherits formatting from the style definition stored with the drawing. This behavior results in smaller files, but also allows changes to the master's formulas or the style definition to be propagated to all instances.

Black text in a cell indicates an inherited formula.

When you write a local formula for an instance, you are replacing the inherited formula in the cell with a local override. Future changes to that cell in the master or style do not affect this instance because it has blocked inheritance for the cell with the local override.

Applying a style deletes all local formulas in the related cells unless you use the GUARD function to protect them.

Blue text indicates a local formula, either the result of editing the formula in a ShapeSheet window or some change to the shape that caused Visio to reset the formula for that cell.

Visio automatically updates certain cells whenever you change a shape in a drawing. This means that under some circumstances formulas you enter can be replaced. For example, if you drag a corner handle to resize a shape, Visio resets formulas in the PinX, PinY, Width, and Height cells.

If necessary, you can protect formulas against changes by using the GUARD function.