MS Excel: Choose Function
In Excel, the Choose function returns a value from a list of values based on a given position.
The syntax for the Choose function is:
Choose( position, value1, value2, ... value_n )
position is position number in the list of values to return. It must be a number between 1 and 29.
value1, value2, ... value_n is 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.
Note:
If position is less than 1, the Choose function will return #VALUE!.
If position is greater than the number of the number of values in the list, the Choose function will return #VALUE!.
If position is a fraction (not an integer value), it will be converted to an integer by dropping the fractional component of the number.
Applies To:
- Excel 2007, Excel 2003, Excel XP, Excel 2000
For example:
Let's take a look at an example:
=Choose(1, "Tech", "on", "the", "Net") would return "Tech" =Choose(2, "Tech", "on", "the", "Net") would return "on" =Choose(3, "Tech", "on", "the", "Net") would return "the" =Choose(4, "Tech", "on", "the", "Net") would return "Net" =Choose(5, "Tech", "on", "the", "Net") would return #VALUE! =Choose(3.75, "Tech", "on", "the", "Net") would return "the"
VBA Code
The Choose function can also be used in VBA code. For example:
Dim LValue As String
LValue = Choose(1, "Tech", "on", "the", "Net")
In this example, the variable called LValue would contain "Tech" as a value.