Edit

Share via


WorksheetFunction.Choose Method

Definition

Uses Arg1 as the index to return a value from the list of value arguments.

public object Choose (object Arg1, object Arg2, object Arg3, object Arg4, object Arg5, object Arg6, object Arg7, object Arg8, object Arg9, object Arg10, object Arg11, object Arg12, object Arg13, object Arg14, object Arg15, object Arg16, object Arg17, object Arg18, object Arg19, object Arg20, object Arg21, object Arg22, object Arg23, object Arg24, object Arg25, object Arg26, object Arg27, object Arg28, object Arg29, object Arg30);
Public Function Choose (Arg1 As Object, Arg2 As Object, Optional Arg3 As Object, Optional Arg4 As Object, Optional Arg5 As Object, Optional Arg6 As Object, Optional Arg7 As Object, Optional Arg8 As Object, Optional Arg9 As Object, Optional Arg10 As Object, Optional Arg11 As Object, Optional Arg12 As Object, Optional Arg13 As Object, Optional Arg14 As Object, Optional Arg15 As Object, Optional Arg16 As Object, Optional Arg17 As Object, Optional Arg18 As Object, Optional Arg19 As Object, Optional Arg20 As Object, Optional Arg21 As Object, Optional Arg22 As Object, Optional Arg23 As Object, Optional Arg24 As Object, Optional Arg25 As Object, Optional Arg26 As Object, Optional Arg27 As Object, Optional Arg28 As Object, Optional Arg29 As Object, Optional Arg30 As Object) As Object

Parameters

Arg1
Object

Specifies which value argument is selected. Arg1 must be a number between 1 and 29, or a formula or reference to a cell containing a number between 1 and 29.

Arg2
Object

1 to 29 value arguments from which Choose selects a value or an action to perform based on Arg1. The arguments can be numbers, cell references, defined names, formulas, functions, or text.

Arg3
Object
Arg4
Object
Arg5
Object
Arg6
Object
Arg7
Object
Arg8
Object
Arg9
Object
Arg10
Object
Arg11
Object
Arg12
Object
Arg13
Object
Arg14
Object
Arg15
Object
Arg16
Object
Arg17
Object
Arg18
Object
Arg19
Object
Arg20
Object
Arg21
Object
Arg22
Object
Arg23
Object
Arg24
Object
Arg25
Object
Arg26
Object
Arg27
Object
Arg28
Object
Arg29
Object
Arg30
Object

Returns

Remarks

If Arg1 is 1, Choose returns value1; if it is 2, Choose returns value2; and so on.

If Arg1 is less than 1 or greater than the number of the last value in the list, Choose generates an error.

If Arg1 is a fraction, it is truncated to the lowest integer before being used.

If Arg1 is an array, every value is evaluated when Choose is evaluated.

The value arguments to Choose can be range references as well as single values. For example, the formula:

=SUM(Choose(2,A1:A10,B1:B10,C1:C10))

evaluates to:

=SUM(B1:B10)

which then returns a value based on the values in the range B1:B10.

The Choose function is evaluated first, returning the reference B1:B10. The SUM function is then evaluated using B1:B10, the result of the Choose function, as its argument.

Applies to