Choosing Cases With SWITCH
Map an input to one of several results using SWITCH.
Choosing Cases With SWITCH is a free Excel Formulas Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why SWITCH Exists
When you are comparing one value against a list of exact possibilities, nested IFs get repetitive. You keep typing the same cell reference over and over.
The SWITCH function solves this. You name the value once, then list each possible match alongside the result it should produce. It reads like a clean lookup table written inside a single formula.
The SWITCH Syntax
The structure is: SWITCH(expression, value1, result1, value2, result2, ..., default).
- expression is the thing you are evaluating, usually a cell.
- Then you pair each possible value with its result.
- An optional default at the end catches anything that did not match.
The values come in pairs, with a lone default allowed at the very end.
=SWITCH(A2, "N", "North", "S", "South", "Unknown")A First Worked Example
Imagine a day number 1 through 7 in cell A2 and you want the weekday name. SWITCH maps each number to a label.
SWITCH compares the expression to each value using exact equality, so 1 matches only 1, never "close to 1".
=SWITCH(A2,1,"Mon",2,"Tue",3,"Wed",4,"Thu",5,"Fri",6,"Sat",7,"Sun")Adding a Default Catch-All
What if cell A2 holds a value you never listed, like 8 or a typo? Without a default, SWITCH returns the #N/A error.
Add one final argument with no matching value in front of it. SWITCH treats a lone trailing argument as the default to use when nothing matched.
=SWITCH(A2,1,"Mon",2,"Tue",3,"Wed","Invalid day")SWITCH Compares Exactly
This is the most important rule: SWITCH only checks for exact equality. It cannot do "greater than" or "between" tests.
So SWITCH is perfect for codes, IDs, statuses, and category names. It is the wrong choice for grading by score ranges. For ranges, you still need nested IFs or IFS with comparison tests.
=SWITCH(B2,"A","Approved","P","Pending","R","Rejected","Review")SWITCH Versus Nested IF
Compare the same logic both ways. With nested IF you repeat A2 three times:
=IF(A2="N","North",IF(A2="S","South",IF(A2="E","East","West")))
With SWITCH you name A2 just once and the rest is clean pairs. Fewer parentheses, less repetition, and far easier to read or edit later.
=SWITCH(A2,"N","North","S","South","E","East","West")Returning Numbers and Formulas
Just like IF, the results in SWITCH can be numbers or even calculations, not only text labels.
Here a shipping code drives a flat fee. A code of STD returns 5, EXP returns 15, and anything else falls to the default fee of 25.
=SWITCH(C2,"STD",5,"EXP",15,25)The Clever TRUE Trick
There is a way to make SWITCH handle ranges after all. Set the expression to TRUE, then make each value a full comparison. SWITCH returns the result of the first comparison that equals TRUE.
This mimics a nested IF range test while keeping the tidy SWITCH layout. Remember to order the comparisons from highest to lowest.
=SWITCH(TRUE, A2>=90,"A", A2>=80,"B", A2>=70,"C", "F")A Deeper Worked Example
A status code in A2 should become a friendly message and a follow-up. We map four codes and provide a safety default:
1means "New order"2means "Shipped"3means "Delivered"4means "Cancelled"- anything else means "Check record"
=SWITCH(A2,1,"New order",2,"Shipped",3,"Delivered",4,"Cancelled","Check record")Availability Note
SWITCH is available in Excel 2019, Excel for Microsoft 365, and Google Sheets. It is not in very old versions like Excel 2013 or earlier.
If you ever open a workbook in an old version, SWITCH may appear as #NAME?. In that case, fall back to nested IFs, which work everywhere.
Best Practices for SWITCH
Get the most from SWITCH by remembering:
- Use it for exact matches: codes, statuses, categories.
- Always add a default to avoid #N/A surprises.
- Keep the value-result pairs lined up so they are easy to scan.
- For range logic, use the
SWITCH(TRUE, ...)trick or stick with IFS.
Quick Check
Test your understanding of how SWITCH compares values.
Recap: Choosing Cases With SWITCH
You learned to map one value to many outcomes with SWITCH. Key points:
- Syntax is
SWITCH(expression, value1, result1, ..., default). - It matches by exact equality, perfect for codes and statuses.
- Always include a default to avoid
#N/A. - Use
SWITCH(TRUE, comparison, result, ...)when you need range logic.
=SWITCH(A2,"N","North","S","South","E","East","West")Frequently asked questions
Is the “Choosing Cases With SWITCH” lesson free?
Yes — the full text of “Choosing Cases With SWITCH” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.
What will I learn in “Choosing Cases With SWITCH”?
Map an input to one of several results using SWITCH. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Excel Formulas Academy?
No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Choosing Cases With SWITCH” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Excel Formulas Academy lesson?
Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Stacking IFs for Multiple Outcomes
- Choosing Cases With SWITCH
- Picking Items With CHOOSE
- Keeping Complex Logic Readable