IF
Checks whether a condition is met, and returns one value if -true, and another value if -false.
Syntax
expression.IF(arg1, arg2, arg3);
expression - A variable that represents a ApiWorksheetFunction class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| arg1 | Required | number | string | ApiRange | ApiName | boolean | Any value or expression that can be evaluated to true or false. | |
| arg2 | Required | number | string | ApiRange | ApiName | boolean | The value that is returned if the condition is true. If omitted, true is returned. You can nest up to seven IF functions. | |
| arg3 | Optional | ApiRange | ApiName | number | string | boolean | The value that is returned if the condition is false. If omitted, false is returned. |
Returns
number | string | boolean
Example
This example shows how to check whether a condition is met, and returns one value if true, and another value if false.
- Code
- Result
// How to check a condition.
// Use a function to use IF condition checker.
let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.IF("12<100", 0, 1));