SETF Function

Office 2013 and later

Last modified: March 09, 2015

Applies to: Office 2013 | Visio 2013

In this article
Syntax
Remarks
Example 1
Example 2
Example 3

Sets a cell's formula.

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.

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.

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

Sets the formula of Scratch.A1 to 21 inches.

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.

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

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

Show: