SWITCH(expression, value1, result1 [,value2, result2] [, default]) |
Returns the value based on the first matching item. |
expression | The expression to be compared to the values. |
value1 | The value to compare. |
result1 | The result if the expression equals the value. |
value2 | (Optional) The value to compare. |
result2 | (Optional) The result if the expression equals the value. |
default | (Optional) The value to return when there are no matches. |
Remarks |
* Added in Excel 2019. * The "values" can be numbers or text. * The "results" can be any expression. * If none of the "values" match and a "default" value has been provided, then the default value is returned. * If none of the "values" match and a "default" value has not been provided, then #N/A! is returned. * You can have a maximum of 126 (values and results). * If the function is not available, then #NAME? is returned. * For the Microsoft documentation refer to support.office.com |
|
1 - What is the first result where the value matches the number "1". 2 - What is the first result where the value matches the number "2". 3 - What is the first result where the value matches the string "findtokyo". 4 - What is the first result where the value matches the string "Tokyo". 5 - What is the first result where the value matches the string "Tokyo". 6 - What is the first result where the value matches the string "findtext". This value is not found so the default value is returned. 7 - What is the first result where the value matches the string "findtext". The value is not found and no default value has been provided. 8 - What is the first result where the value matches the number "3". The value is not found and no default value has been provided. |
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top