Table of Contents
The SWITCH function in excel is a useful tool that allows users to compare a specific value with a list of possible values and return a corresponding result. This function can be used to simplify complex formulas and make them more efficient. To use the SWITCH function, the user must specify the value to be checked, followed by a series of value and result pairs. The function will then return the result that matches the specified value. This function is particularly useful for organizing large data sets and can save time and effort when working with large amounts of data.
The SWITCH function evaluates one value (called the expression) against a list of values, and returns the result corresponding to the first matching value. If there is no match, an optional default value may be returned.
Note: This feature is available on Windows or Mac if you have Office 2019, or if you have a Microsoft 365 subscription. If you are a Microsoft 365 subscriber, make sure you have the latest version of Office.
Syntax
SWITCH(expression, value1, result1, [default or value2, result2],…[default or value3, result3])
Argument | Description |
|---|---|
expression | Expression is the value (such as a number, date or some text) that will be compared against value1…value126. |
value1…value126 | ValueN is a value that will be compared against expression. |
result1…result126 | ResultN is the value to be returned when the corresponding valueN argument matches expression. ResultN and must be supplied for each corresponding valueN argument. |
default | Default is the value to return in case no matches are found in the valueN expressions. The Default argument is identified by having no corresponding resultN expression (see examples). Default must be the final argument in the function. |
Because functions are limited to 254 arguments, you can use up to 126 pairs of value and result arguments.
Overview
In its simplest form, the SWITCH function says:
=SWITCH(Value to switch, Value to match1…[2-126], Value to return if there’s a match1…[2-126], Value to return if there’s no match)
Where you can evaluate up to 126 matching values and results.
See the following formula:

Value to switch? In this case, WEEKDAY(A2) equals 2.
What value do you want to match? In this case, it’s 1, 2 and 3.
If there’s a match, what do you want to return as a result? In this case, it would be Sunday for 1, Monday for 2 and Tuesday for 3.
Default value to return if there’s no match found. In this case, it’s the text “No match”.
Note: If there are no matching values, and no default argument is supplied, the SWITCH function returns the #N/A! error.
Examples
You can copy the example data in the following table and paste it in cell A1 of a new Excel worksheet to see the SWITCH function in action. If the formulas don’t show results, you can select them, then press F2 > Enter. If you need to, you can adjust the column widths to see all the data.
Example
Value | Formula | Result |
|---|---|---|
2 | =SWITCH(WEEKDAY(A2),1,”Sunday”,2,”Monday”,3,”Tuesday”,”No match”) | Because A2=2, and Monday is the result argument corresponding to the value 2, SWITCH returns Monday |
99 | =SWITCH(A3,1,”Sunday”,2,”Monday”,3,”Tuesday”) | Because there’s no match and no else argument, SWITCH returns #N/A! |
99 | =SWITCH(A4,1,”Sunday”,2,”Monday”,3,”Tuesday”,”No match”) | No match |
2 | =SWITCH(A5,1,”Sunday”,7,”Saturday”,”weekday”) | weekday |
3 | =SWITCH(A6,1,”Sunday”,2,”Monday”,3,”Tuesday”,”No match”) | Tuesday |
See Also
Find and correct errors in formulas
Excel keyboard shortcuts and function keys
Cite this article
stats writer (2024). How can I use the SWITCH function in excel?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-the-switch-function-in-excel/
stats writer. "How can I use the SWITCH function in excel?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-the-switch-function-in-excel/.
stats writer. "How can I use the SWITCH function in excel?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-the-switch-function-in-excel/.
stats writer (2024) 'How can I use the SWITCH function in excel?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-the-switch-function-in-excel/.
[1] stats writer, "How can I use the SWITCH function in excel?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How can I use the SWITCH function in excel?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
