The Choose() Function
The Choose() function returns a value chosen from a list of values. The value returned is determined by an index that is passed to the function. This function is like a shortcut for the If Then statement and the Case statement. You can use it when the range of possible values is relatively small and sequential.
The Choose() function works by passing it an index number as the first parameter and a list of return values after it. The index number is used to determine which value is returned. The first position in the list of return values is indexed at 1. For example, if the index number is 3 and there are five values in the list, then the third item would be returned. This function can return any data type except for an array. As expected, each item in the list must be of the same data type.
If the index is a value that is greater than the number of items passed, then the last item in the list is returned. For example, if there are five items in the list and the index number is 10 instead, then the fifth item would be returned because it is last in the list.
The syntax for the Choose() function is as follows:
An example of displaying a person’s place in a race using text is as follows. The range of possible values is 1 to the number of participants. This function will only consider the first three positions. Everyone ranked after that is given a generic classification.