[Table of Contents] [docx version]

SpreadsheetML Reference Material - Table of Contents

IF

Syntax:

IF ( logical-value , [ value-if-true ] [ , [ value-if-false ] ] )

Description: Tests logical-value, and if it is TRUE, value-if-true is evaluated and returned; otherwise, value-if-false is evaluated and returned.

Arguments:

Name

Type

Description

logical-value

logical

The value to be tested.

value-if-true

any

The value returned if logical-value is TRUE. If logical-value is TRUE and value-if-true is omitted, this argument evaluates to 0. value-if-true can contain up to seven levels of nested IF function calls. value-if-true and value-if-false need not evaluate to results of the same type.

value-if-false

any

The value returned if logical-value is FALSE. If logical-value is FALSE and value-if-false and its preceding comma is omitted, this argument evaluates to FALSE. If logical-value is FALSE and value-if-false is omitted, but its preceding comma is present, this argument evaluates to 0. value-if-false can contain at least seven levels of nested IF function calls. value-if-true and value-if-false need not evaluate to results of the same type.

 

If any argument is an array, every element of that array shall be evaluated when that argument is evaluated.

Return Type and Value: any – value-if-true, if logical-value is TRUE; otherwise, value-if-false.

[Example:

IF(10>5,"Yes","No") results in Yes
IF(10>5,"Yes") results in Yes
IF(10>5,"Yes",) results in Yes
IF(10<5,"Yes") results in FALSE
IF(10<5,"Yes",) results in 0

IF(10>5,,"No") results in 0
IF(10>5,,) results in 0
IF(10>5,"Yes",20) results in Yes
IF(10<5,"Yes",20) results in 20

end example]