Choose() Function


The Excel CHOOSE function returns a value from a list using a given position or index. 



Syntax

The syntax for the CHOOSE function in Microsoft Excel is:

=CHOOSE( position, value1, [value2, ... value_n] )

Parameters or Arguments

position

The position number in the list of values to return. It must be a number between 1 and 29.

value1, value2, ... value_n

A list of up to 29 values. A value can be any one of the following: a number, a cell reference, a defined name, a formula/function, or a text value.

Excel Choose Function Examples


Example 1 - Using the Choose Function to Return a Value

Column A of the following spreadsheet shows the Choose function used to return the following colors, depending on the value of the index_num argument:

1 - red; 2 - blue; 3 - green; 4 - brown

Formulas:


A
1
=CHOOSE( 4, "red", "blue", "green", "brown" )
2
=CHOOSE( 2, "red", "blue", "green", "brown" )
3
=CHOOSE( 3, "red", "blue", "green", "brown" )
4
=CHOOSE( 1, "red", "blue", "green", "brown" )

Results:


A
1
brown
2
blue
3
green
4
red

Example 2 - Using the Choose Function to Return a Cell Reference

The Excel Choose function can also return cell references, as shown in the following example. In this case, the reference that is returned from the Choose function is then provided to the Excel SUM Function.

Formulas:


A
B
C
1
10
3
=SUM( CHOOSE( B1, A1, A1:A2, A1:A3, A1:A4 ) )
2
11


3
12


4
13



Results:


A
B
C
1
10
3
33
2
11


3
12


4
13



In the example above, the Choose function returns the cell reference A1:A3. This is then passed to the SUM function which calculates the sum of the values in the cell range A1:A3 and returns the value 33.

Notes

   If the position is <0, then it will return #NUM error.
   If the position is greater than the supplied number, then it will return #NUM error.
   If the position is non-numeric, then it will return #VALUE error.

References



No comments:

Post a Comment

OR Function