How to use the CHOOSE function
The CHOOSE function lets you get a value based on a number, the number determines which value to get. The first value is 1 and the second value is 2 and so on.
Formula in cell E3:
The CHOOSE function demonstrated above uses the specified number in cell D3 to get a value from cells B3, B4, and B5. Number two returns the value in cell B4. Cell B4 is the second cell reference.
Note, you can't use a cell range containing multiple values. You need to type each cell separated by a comma. There is an exception to this demonstrated later in this article.
Table of Contents
1. Syntax
2. Arguments
Argument | Text |
Index_num | Determines which value is chosen. This argument is required, you can use a number between 1 and 254. |
value1, value2, value3 | Up to 254 values Index_num can pick from. The first value is required the remaining values are optional. |
3. Example
The picture above displays a formula that allows you to select a cell range and then a SUM function adds all numbers in the selected cell range.
Formula in cell C3 selects cell range C8:C10 and adds the numbers 300 + 400 + 500 = 1200 is shown in cell C3.
Array formula in cell C3:
3.1 How to enter an array formula
- Copy the array formula above.
- Double press with the left mouse button on cell C3, a prompt appears.
- Paste it to cell C3, shortcut keys are CTRL + v.
- Press and hold CTRL + SHIFT keys simultaneously.
- Press Enter once.
- Release all keys.
The formula bar shows a beginning and ending curly bracket, don't enter these characters yourself.
They appear automatically if you followed the above steps.
3.2 Explaining formula
Step 1 - Choose cell reference
CHOOSE(B3, B8:B11, C8:C11, D8:D11)
becomes
CHOOSE(2, B8:B11, C8:C11, D8:D11)
becomes
C8:C10
and returns {300; 400; 500}. Cell reference C8:C10 is the second cell reference.
Step 2 - Add numbers and return a total
The SUM function calculates a sum based on a given set of numbers. It works fine with arrays as well.
SUM(number1, [number2], ...)
SUM(CHOOSE(B3, B8:B11, C8:C11, D8:D11))
becomes
SUM({300; 400; 500})
and returns 1200 in cell C3.
4. How to hardcode values
Use function key F9 to quickly create hard-coded values from a specific cell range, then use the values in the CHOOSE function.
- Double-press with left mouse button on an empty cell.
- Type = (equal sign)
- Select a cell range with your mouse or type a cell range.
- Press F9 to convert values in cell range to "constants" or hard-coded values.
- Delete the curly brackets { }.
- Replace semicolons with colons.
- Use the values in your CHOOSE function.
5. Array
The CHOOSE function can't work with arrays or cell ranges, it returns a #VALUE error if you try.
Formula in cell C3:
What can you do about it? Use the INDEX function, see the example below.
6. Alternative formula
Formula in cell C3:
The INDEX function has the following arguments:
INDEX(array, [row_num], [col_num], [area_num])
Explaining formula in cell C3
INDEX({"Red";"Blue";"Green"},B3)
becomes
INDEX({"Red";"Blue";"Green"},2)
and returns "Blue" in cell C3. "Blue" is the second value in the array.
7. Drop-down list
The image above shows a drop-down list in cell C4, it is populated with values from a given column in B8:D12 based on the number specified in cell B3.
For example, cell B3 contains 2. The drop-down list is populated with values from the second column. Change the number to 3 in cell B3 and the drop-down list is instantly and automatically populated with values from column 3.
Drop-down list formula:
7.1 How to insert a drop-down list
- Go to tab "Data" on the ribbon.
- Press with the left mouse button on button "Data Validation", a dialog box appears.
- Press with the left mouse button on drop-down list "below "Allow:" and change it to "List".
- Press with left mouse button on in the field below "Source" and type the following formula:
=CHOOSE(B3,B8:B11,C8:C10,D8:D12)
- Press with the left mouse button on "OK" button.
8. CHOOSE and VLOOKUP
This picture above demonstrates a VLOOKUP function combined with the CHOOSE function, the CHOOSE function lets you use two different data sets in B7:E11 and B15:E18. Cell C3 contains a number that determines which data set to be used.
Formula in cell E3:
8.1 Explaining formula
Step 1 - Choose cell reference
CHOOSE(C3, B7:E11, B15:E18)
becomes
CHOOSE(2, B7:E11, B15:E18)
and returns B15:E18.
Step 2 - Find value in the chosen data set
The VLOOKUP function lets you search the leftmost column for a value and return another value on the same row in a column you specify.
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
VLOOKUP(B3, CHOOSE(C3, B7:E11, B15:E18), D3, FALSE)
becomes
VLOOKUP(B3, B15:E18, D3, FALSE)
becomes
VLOOKUP("C", B15:E18, 3, FALSE)
and returns the value in D18. "C" is found on row 18 in the leftmost column in B15:E18. The third argument col_index_num is 3. The intersection of row 18 and the third column is D18.
9. Return array
The image above demonstrates how to return an array of values using the CHOOSE function.
Array formula in cell D3:
Excel 365 users can enter this formula as a regular formula, previous Excel versions need to enter this as an array formula.
9.1 Explaining formula
CHOOSE(B3,{2;3;1}, {4;2;6})
becomes
CHOOSE(2,{2;3;1}, {4;2;6})
and returns {4;2;6}. The CHOOSE function returns the second array.
This array has a semicolon as a delimiting character, this means that the values are vertically arranged in the array. This is why you get an array of values in column D, see the image above.
10. From list
The picture above shows the CHOOSE function in cell F3, one disadvantage is that you need to press with left mouse button on each cell in the list to build the formula.
If you have a long list that will take some time, however, there is a workaround.
You can quickly convert a cell range to hard-coded values, here are the steps.
- Double press with left mouse button on a cell
- Type =CHOOSE(E3,TRANSPOSE(C3:C12))
- Select TRANSPOSE(C3:C12) in the formula with your mouse
- Press function key F9 to convert the cell reference to values
- Delete the curly brackets { }
- Press Enter
Note, you don't need the TRANSPOSE function if your values are arranged horizontally.
However, the CHOOSE function allows you to have up to 254 arguments, and perhaps hardcoded values are not what you want. If you have more than 254 values you need another solution, demonstrated below.
The INDEX function allows you to choose a value from a cell range without the need to select each value while building the formula.
11. Function not working
The CHOOSE function returns
- #VALUE! error if you use a number outside the range.
- #NAME? error if you misspell the function name.
- propagates errors, meaning that if the input contains an error (e.g., #VALUE!, #REF!), the function will return the same error.
11.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
11.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference D3 converted to hard-coded value using the F9 key. The CHOOSE function requires valid numerical values which is not the case in this example. There are only three values, number four is outside the range. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
11.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
Useful links
Excel CHOOSE function with formula examples
CHOOSE function - Microsoft
'CHOOSE' function examples
Table of Contents How to perform a two-dimensional lookup Reverse two-way lookups in a cross reference table [Excel 2016] Reverse […]
Table of Contents Split data across multiple sheets - VBA Add values to worksheets based on a condition - VBA […]
The image above shows how to summarize work hours using the new GROUPBY function in Excel 365. This is demonstrated […]
Functions in 'Lookup and reference' category
The CHOOSE function function is one of 25 functions in the 'Lookup and reference' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form