CHOOSE()

Syntax. CHOOSE(index,value1,value2,...)

Definition. This function uses an index to return a value from the value argument list.

Arguments

  • index (required). Indicates the item that is selected from the value arguments.

  • value1,value2,... (the first value argument is required). Value arguments divided by commas. These arguments can be numbers, cell references, defined names, formulas, functions, or text. In Excel 2007 and Excel 2010, the number of arguments is restricted to 254, and in earlier versions the limit is 29.

Background. The index argument must evaluate to an integer from 1 through 29 or 1 through 254.

You can use a formula or reference to a cell returning such a number. If index is smaller than 1 or greater than the number of value arguments in the list, the CHOOSE() function returns the #VALUE! error. If index is a fraction, the decimal places are truncated before a value is returned.

You can use CHOOSE() in an array formula if you specify the index as an array. But take care to avoid errors: The formula

{=CHOOSE({1;2},SUM(E41:G41),SUM(E42:G42))}

returns the sum of E41 through G41 in the first cell, and the sum of E42 and G42 in the second cell. The formula

{=SUM(CHOOSE({1;2},E41:G41,E42:G42))}

returns the total of E41 through G42 in both cells. The formulas

=SUM(CHOOSE(1,E41:G41,E42:G42))

and

=SUM(CHOOSE(2,E41:G41,E42:G42))

return the correct results.

Example. Assume that you have entered the names of the days, starting with Sunday, in cells B42 through B48. The formula

="Today is " & CHOOSE(WEEKDAY(D42),B42,B43,B44,B45,B46,B47,B48) & "."

returns Today is [weekday name].

See Also

INDEX()

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.137.12