Excel SWITCH function
The SWITCH function in Excel is used to compare one value against a list of values, and returns a result corresponding to the first match, if no match is found, an optional default value is displayed.
The syntax for the SWITCH function in Excel is:
|Type of Expression||Example|
|Logical test||A2= “KTE”|
|Number or text||2 or “KTE”|
|Boolean values||TRUE or FALSE|
Returns a corresponding value to the first match.
Example 1: Simple use of SWITCH function
For example, I want to use Monday to replace the number 1, Tuesday to replace the number 3, and Sunday to replace the number 7, other numbers will be replaced by No Match.
This SWITCH function can solve this job as quickly as you can.
Please enter this formula:
Example 2: Combine SWITCH function with other functions
Supposing, you have a worksheet with a column of dates, now, you want to determine if a date is occurring today, yesterday or tomorrow. In this case, you can use the TODAY function to return the serial number of the current date, and DAYS to return the number of days between two dates.
Please apply the following formula, and all the matched values have been returned into the cell based on the date.