How to Match Exact Values with SWITCH in Excel
Translate codes into labels, rates or messages with SWITCH — one value compared against a list of exact matches.
You will learn to
- Translate short codes into readable names
- Return a number from SWITCH and calculate with it
- Switch on the result of another function
How it works
SWITCH compares one expression against a list of values and returns the result paired with the first exact match: =SWITCH(C2,"CC","Credit card","PP","PayPal","Unknown"). The last, unpaired argument is the default returned when nothing matches; without it, an unmatched value gives #N/A.
SWITCH is ideal when you are matching exact codes rather than ranges. Because the expression is only written once, it also works well on calculated values such as =SWITCH(WEEKDAY(B2,2),6,"Weekend",7,"Weekend","Weekday").
=SWITCH(C2,"CC","Credit card","PP","PayPal","Unknown")