When you’re mapping one value to another — a code to a label, a number to a name — SWITCH is cleaner than a stack of IFs. It compares one expression against a list of cases and returns the first match.
The example
Status codes mapped to labels.
| A | B | |
|---|---|---|
| 1 | Code | Status |
| 2 | 1 | New |
| 3 | 3 | Closed |
| 4 | 9 | Unknown |
The formula
The label in B2:
How it works
SWITCH reads as value / result pairs:
- The first argument is the expression to test —
A2. - Then come pairs: a value to match and the result to return.
1, "New"means “if A2 is 1, return New.” - SWITCH returns the first matching result and stops.
- A final lone argument (no pair) is the default when nothing matches — here, “Unknown.”
SWITCH vs IFS. Use SWITCH when you’re comparing one thing to many exact values. Use IFS when each branch is a different condition (ranges, comparisons). For a position-based pick (1st, 2nd, 3rd item), CHOOSE is simplest.
Try it: interactive demo
Pick a code; see the mapped label.
Variations
Text codes too
SWITCH works on text values:
Legacy: nested IF or lookup
Pre-2019, use a small lookup table with XLOOKUP/VLOOKUP, or nested IF.
Pick by position with CHOOSE
When codes are 1,2,3 in order:
Pitfalls & errors
SWITCH needs Excel 2019+. Older versions show #NAME? — use nested IF or a lookup table.
SWITCH matches exact values, not ranges. For “greater than” logic use IFS; SWITCH can fake ranges only with a TRUE trick.
No default = #N/A. Without the final lone argument, an unmatched value returns #N/A. Always add a default.
Practice workbook
Frequently asked questions
How do I use the SWITCH function in Excel?
What's the difference between SWITCH and IFS?
How do I do SWITCH in older Excel?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class