Skip to main content

CHOOSE

Chooses a value or action to perform from a list of values, based on an index number.

Syntax

expression.CHOOSE(arg1, args);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | numberThe position of the value in the list of values, a numeric value greater than or equal to 1 but less than the number of values in the list of values.
argsRequirednumber | string | ApiRange | ApiNameUp to 254 values or the selected range of cells to analyze.\ The first argument is required, subsequent arguments are optional. Arguments can be numbers, ranges, names, or text strings.

Returns

number

Example

let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue(func.CHOOSE(2, 3, 4, 89, 76, 0));