Share via


SETF Function

Sets a cell's formula.

Syntax

SETF( GETREF(cell), formula)

Parameters

Name

Required/Optional

Data Type

Description

cell

Required

String

The cell whose formula to set.

formula

Required

String

The formula to use.

Remarks

When evaluated, the result of the expression in formula becomes the new formula in cell. If formula is enclosed in quotation marks, the quoted expression is written to cell. To set cell to a string, enclose formula in three sets of quotation marks.

The target cell must be specified using a GETREF() reference or as a string to avoid circularity. Using GETREF is preferred, because Microsoft Visio can adjust references when the shape is moved to a different document.

If cell is not specified using GETREF or as a string, the function returns an error, and no cell's formula is changed. If formula contains a syntax error, the function returns an error, and the formula in cell is not changed.

Example 1

SETF( GETREF(Scratch.A1), 1.5 in * 6 + 1 ft)

Sets the formula of Scratch.A1 to 21 inches.

Example 2

SETF( GETREF(Scratch.A1), "1.5 in * 6 + 1 ft")

Sets the formula of Scratch. A1 to the expression 1.5 in*6+1 ft.

Example 3

SETF( GETREF(Scratch.A1), """Say """"ahh""""""")

Sets the formula of Scratch.A1 to the string "Say ""ahh""" which evaluates to Say "ahh".