IF

Macro Sheets Only

Used with ELSE, ELSE.IF, and END.IF to control which formulas in a macro are executed. There are two syntax forms of the IF function. The following syntax can be used on macro sheets only; use it when you want your macro to branch to a particular set of functions based on the outcome of a logical test. The worksheet form of this function can be used on worksheets and macro sheets.

Syntax

IF(logical_test)

Logical_test is a logical value that IF uses to determine which functions to carry out next—that is, where to branch.

Tips

Example

The following macro runs the macro CompleteEntry if the user chooses OK:


IF(ALERT("Are you done with this entry?", 1), CompleteEntry(), )

Tip You can indent formulas in a macro. To indent a formula, type as many spaces as you want between the equal sign and the first letter of the formula.

Related Functions

ELSE Specifies an action to take if an IF function returns FALSE

ELSE.IF Specifies an action to take if an IF or another ELSE.IF function returns FALSE

END.IF Ends a group of macro functions started with an IF statement

ERROR Specifies what action to take if an error occurs while a macro is running

List of Control Functions