The Excel SWITCH function compares one value with a list of options and returns the result paired with the first match. Type =SWITCH(E2,1,"Packed",2,"In transit",3,"Out for delivery",4,"Delivered","Unknown code") and a status code of 2 shows In transit. The last lone argument is the default for anything that matches nothing.
Functions
SWITCH Function in Excel: Syntax, Default, Examples
Try this now
| A | B | C | D | |
|---|---|---|---|---|
| 1 | 1 | |||
| 2 | 2 | |||
| 3 | 3 | |||
| 4 | 4 | |||
| 5 | 5 |
You are typing into B1. Refer to the cells that hold the data.
Ready to practice?
Apply what you just learned with interactive exercises.
This guide covers the syntax, the default value, text and number matching, SWITCH(TRUE) for ranges, the traps, and when IFS or CHOOSE is the better tool.
TL;DR
- The pattern is =SWITCH(expression, value1, result1, value2, result2, ..., default). Excel evaluates the expression once, then walks the pairs.
- The default is optional and sits last, with no partner. Leave it out and an unmatched value returns #N/A.
- SWITCH matches exactly. It does not do greater-than or less-than, and it does not understand wildcards.
- Text matching ignores capital letters, but the text "1" does not match the number 1.
- To test ranges, use SWITCH(TRUE, test1, result1, test2, result2, ...). For many ranges, IFS usually reads better.
- SWITCH needs Excel 2019, Excel 2021, Excel 2024 or Microsoft 365. Older Excel shows #NAME?.
Table of Contents
- Sample data for the SWITCH examples
- SWITCH syntax and arguments
- How to use the SWITCH function in Excel
- SWITCH default value for unmatched cases
- SWITCH with text codes
- SWITCH with a formula as the expression
- SWITCH with calculated results
- SWITCH TRUE for ranges and multiple conditions
- When SWITCH does not match
- SWITCH compared with IFS, nested IF and CHOOSE
- Which Excel versions have SWITCH
- SWITCH errors and how to fix them
- What learners get wrong
- A worked job: the parcel desk
- Practice the SWITCH function
- FAQ
- Sources
Sample data for the SWITCH examples
The examples use a courier desk's parcel list. Row 1 holds the headings and the parcels sit in rows 2 to 7. The service code in column B is a three-letter code, the status in column E is a number from 1 to 4 (1 is packed, 2 in transit, 3 out for delivery, 4 delivered), and the ship dates in column F are real Excel dates. Column G holds the shipping cost that the worked job builds near the end.
| Row | A: Parcel | B: Service | C: Zone | D: Weight kg | E: Status | F: Ship date | G: Cost |
| 1 | Parcel | Service | Zone | Weight kg | Status | Ship date | Cost |
| 2 | P-5001 | EXP | 1 | 0.8 | 4 | 2026-11-02 | 7.2 |
| 3 | P-5002 | STD | 2 | 3.5 | 2 | 2026-11-03 | 17.5 |
| 4 | P-5003 | eco | 3 | 12 | 3 | 2026-11-06 | 36 |
| 5 | P-5004 | STD | 4 | 24 | 1 | 2026-11-07 | 120 |
| 6 | P-5005 | EXP | 2 | 6.2 | 9 | 2026-11-08 | 55.8 |
| 7 | P-5006 | XPR | 1 | 18 | 2 | 2026-11-04 | 0 |
SWITCH syntax and arguments
=SWITCH(expression, value1, result1, [default_or_value2, result2], ...)
| Argument | Required | What it does |
| expression | Yes | The value to test. A cell, a number, text or a formula. Excel works it out once. |
| value1 | Yes | The first value to compare the expression with. |
| result1 | Yes | What to return if the expression equals value1. |
| default_or_value2, result2 | No | More pairs. A single argument at the very end, with no partner, is the default. |
How does Excel know the last argument is a default and not another value? By counting. Pairs use two arguments each. If an argument is left over at the end with no partner, it is the default.
How to use the SWITCH function in Excel
The status column is the textbook case: one cell, a handful of exact values, one label each.
=SWITCH(E2,1,"Packed",2,"In transit",3,"Out for delivery",4,"Delivered")
Row 2 holds 4, so Excel skips the pairs for 1, 2 and 3, hits 4 and shows Delivered. Row 3 holds 2 and shows In transit. Row 4 holds 3 and shows Out for delivery. Row 5 holds 1 and shows Packed.
Compare the same job as a nested IF and you see why people reach for SWITCH. The nested version repeats E2= in every test and closes with three brackets. SWITCH names the cell once and lists the pairs. If you add a fifth status, you add one pair and nothing else.
Our IF function guide covers the nested version if you need it for older Excel.
SWITCH default value for unmatched cases
Row 6 has a status of 9. Run the formula above on it and you see the problem:
=SWITCH(E6,1,"Packed",2,"In transit",3,"Out for delivery",4,"Delivered")
Nothing matches 9 and there is no default, so the cell shows #N/A. That error is useful while you are building, because it flags bad data. On a report it looks broken.
Add one more argument at the end and it becomes the default:
=SWITCH(E6,1,"Packed",2,"In transit",3,"Out for delivery",4,"Delivered","Unknown code")
Row 6 now shows Unknown code, and the other rows return the same labels as before. The default must be the last argument and must have no partner. If you add a value after it, Excel reads the default as a value and the final argument becomes its result.
A default can also be a formula. "Unknown code" could be "Check status " & E6 to show the bad number in the message. Use the default to tell the reader what to do, not just that something failed.
Do not use IFERROR as the default. It would hide a real mistake, such as a misspelled reference, along with the unmatched value.
SWITCH with text codes
SWITCH works on text as well as numbers. The service codes decode like this:
=SWITCH(B2,"EXP","Express","STD","Standard","ECO","Economy","Check code")
Row 2 holds EXP and shows Express. Row 3 shows Standard. Row 7 holds XPR, which is not on the list, so it falls to Check code.
Row 4 holds eco in lowercase, and it still returns Economy. Text comparison in SWITCH ignores capitals, the same way the equals sign does. If you need the capitals to count, SWITCH cannot help on its own. Wrap the expression and the values in EXACT inside a SWITCH(TRUE) formula, or use a different approach.
Spaces count, though. A code typed as "EXP " with a trailing space will not match "EXP". When data comes from a form or an export, put TRIM around the expression: SWITCH(TRIM(B2), ...).
SWITCH with a formula as the expression
The first argument can be a formula, and that is where SWITCH becomes more useful than it first looks. WEEKDAY turns a date into a number from 1 to 7 when you give it a return type of 2, with Monday as 1. You can sort the dates into weekday or weekend with one SWITCH:
=SWITCH(WEEKDAY(F2,2),6,"Weekend",7,"Weekend","Weekday")
Row 2 is Monday 2 November 2026, so the result is Weekday. Row 5 is Saturday 7 November and row 6 is Sunday 8 November, so both show Weekend. SWITCH has no way to give several values the same result, so 6 and 7 each get their own pair. That repetition is the price of an exact-match tool.
Excel evaluates WEEKDAY(F2,2) once and compares that single number with each value. If you had written the nested IF version, WEEKDAY would run again in every test. For a short list that does not matter, but it keeps long formulas shorter. For more on the date function, see our WEEKDAY guide.
SWITCH with calculated results
The result can be a number or a calculation, as long as you leave off the quotes. A shipping cost that depends on the service:
=SWITCH(B2,"EXP",D2*9,"STD",D2*5,"ECO",D2*3,0)
Row 2 is an 0.8 kg express parcel, so the cost is 7.2. Row 3 is 3.5 kg standard, so 17.5. Row 4 is 12 kg economy, so 36. Row 5 is 24 kg standard, so 120. Row 6 is 6.2 kg express, so 55.8. Row 7 has the unknown code XPR and falls to the default 0.
Having 0 as the default is a choice, and a risky one. A parcel priced at zero looks like a free parcel rather than a data error. The worked job below counts those zeros so nothing slips through. A text default such as "Check code" would be safer on its own, but it would turn the column into mixed text and numbers and break SUM. Pick the default that does least harm when it is wrong.
SWITCH TRUE for ranges and multiple conditions
Exact matching is SWITCH's limit. It cannot ask "is the weight under 5 kg?" But there is a well-known workaround. Give SWITCH the value TRUE as the expression, and write the tests as the values:
=SWITCH(TRUE,D2<=1,"Small",D2<=5,"Medium",D2<=20,"Large","Freight")
Excel compares TRUE with each test in turn. The first test that is TRUE matches and returns its label. Row 2 (0.8 kg) is Small. Row 3 (3.5 kg) is Medium. Row 4 (12 kg) is Large. Row 5 (24 kg) is Freight. Row 6 (6.2 kg) is Large, and row 7 (18 kg) is also Large.
The trick works for combinations too. Zones 1 and 2 are metro, zone 3 is regional, and anything else is remote:
=SWITCH(TRUE,OR(C2=1,C2=2),"Metro",C2=3,"Regional","Remote")
Row 2 shows Metro, row 4 shows Regional, and row 5 shows Remote.
Be honest about this pattern. SWITCH(TRUE) does the same job as IFS, but with a more confusing shape. Anyone reading it has to know the trick. If you control the workbook and everyone has Excel 2019 or later, our IFS guide shows the cleaner way to write the same formula.
When SWITCH does not match
Most "my SWITCH returns the default" problems come from three causes.
Text where you meant a number. Zone numbers in column C are real numbers. If the values in your formula are quoted, they are text:
=SWITCH(C2,"1","Metro","2","Metro","Remote")
C2 holds the number 1, and the text "1" is a different kind of value, so nothing matches. Row 2 shows Remote. The same thing happens the other way round when numbers arrive as text from an export. Check with ISNUMBER, or look for the green triangle in the cell corner.
Wildcards. Functions like COUNTIF read an asterisk as "any characters". SWITCH does not:
=SWITCH(B2,"E*","Express","Other")
B2 holds EXP, which you might expect to match "E*", but the result is Other, because SWITCH reads the asterisk as a literal character. For pattern matching use COUNTIF with wildcards or SEARCH. See our wildcard characters guide.
Case and spaces. Capital letters do not matter, as the lowercase eco in row 4 showed. Extra spaces do, so clean the input with TRIM.
SWITCH compared with IFS, nested IF and CHOOSE
Four formulas can turn a code into a label. They suit different jobs.
| Tool | Matches | Best for | Weak spot |
| SWITCH | One expression against exact values | Status codes, labels, exact choices | No ranges. No several-values-one-result |
| IFS | A list of independent tests | Ranges, thresholds, mixed conditions | No built-in default. Add TRUE as the last test |
| Nested IF | Two or three outcomes | Files that must open in older Excel | Long and bracket-heavy past three levels |
| CHOOSE | A position number | Codes that are just 1, 2, 3 in order | Out-of-range numbers return #VALUE! |
| Lookup table | A key in a table | Codes that change, or lists with many rows | Needs a table and a lookup function |
=CHOOSE(E2,"Packed","In transit","Out for delivery","Delivered")
Row 2 holds 4 and returns Delivered. It is shorter than SWITCH, but it only works when the codes are the whole numbers 1, 2, 3 and so on. Row 6 holds 9, which is past the last choice, so CHOOSE returns #VALUE!. SWITCH is the better tool when the codes are not a neat sequence, such as 10, 20 and 30, or when they are text.
If the code list is long, or if people outside your team will edit it, move the codes into a table on a sheet and use a lookup. You change the table and never touch the formula. See VLOOKUP or XLOOKUP.
The short rule: exact values, use SWITCH. Ranges, use IFS. Positions 1 to n, use CHOOSE. Codes that change, use a lookup table.
Which Excel versions have SWITCH
SWITCH arrived in Excel 2019. It works in Excel 2019, Excel 2021, Excel 2024 and Microsoft 365, in Excel for the web, and in the Mac editions of those releases. It is not available in Excel 2016 without a Microsoft 365 subscription, nor in Excel 2013 or earlier.
The practical risk is a shared file. When someone on Excel 2016 opens a workbook that contains SWITCH, the cell shows #NAME?. If you cannot control who opens the file, write the formula as a nested IF or a lookup instead.
SWITCH errors and how to fix them
| What you see | Cause | Fix |
| #N/A | No value matched and there is no default, as in =SWITCH(E6,1,"Packed",2,"In transit") | Add a default as the last argument |
| #NAME? | The workbook is open in an Excel version without SWITCH, or the name is misspelled | Check the version and the spelling |
| Default returned for a value that looks right | Text versus number mismatch, or a trailing space | Check with ISNUMBER and use TRIM |
| Wrong label with no error | A default hides a missing pair, or the arguments are misaligned | Count the arguments: the expression, then pairs, then at most one lone default |
| "Too few arguments" message | Fewer than three arguments | Give SWITCH an expression and at least one value and result |
=SWITCH(E2,"Packed",2,"In transit")
Excel reads "Packed" as the first value, 2 as its result, and "In transit" as the default. E2 holds 4, which is not "Packed", so the cell shows In transit. The formula is valid, so there is no error to warn you.
What learners get wrong
Between 26 September and 3 November 2026, learners made 1,129 first attempts across our SWITCH Function lesson, and 83.4% were right. These are first checks of a screen in a page view, not people. The sticking points are small and specific.
The hardest screen asks for a SWITCH formula with a default of "unknown" after the pairs for 1, 2 and 3. Of 112 first attempts, 60.7% were right. The correct answer is =SWITCH(A1,1,"one",2,"two",3,"three","unknown"). The pattern behind most wrong answers is not a syntax error. In 24 of the first attempts, the learner typed just the result word one where the screen wanted a formula, and 4 typed just unknown. The screen needs the whole formula, and the default is the last argument with no partner.
A second screen shows a formula and asks what it returns. Of 115 first attempts, 65.2% were right. The formula is =SWITCH(A1,1,"One",2,"Two",3,"Three"), with 1 in A1, and the answer is One. Eight first attempts listed all three labels at once, and six typed the formula back as the answer. Both come from the same misreading. SWITCH returns one result, the one beside the first match, never the whole list. When you read a SWITCH, find the match first and then look one step to its right.
The "add another pair" screen had 117 first attempts and 84.6% right. Its wrong answers show how brackets go missing. Three first attempts typed =SWITCH(A1,1,"one",2,"two" and stopped before the closing bracket. Type the closing bracket yourself rather than counting on Excel to add it, and the answer checker compares exactly what you typed. One more dropped the first value and typed =SWITCH(A1,"One",2,"Two"). This is the misaligned case from the errors section, and it is dangerous because it is valid. With 1 in A1, Excel reads "One" as the first value, 2 as its result, and "Two" as the default. The cell shows Two, not an error.
The first screen of the lesson, with 126 first attempts and 84.9% right, mostly catches typing slips: a function name spelled with the letters swapped, a closing quote forgotten, and a result typed without quotes. A text result always needs double quotes.
A worked job: the parcel desk
You manage a courier desk and need the Monday sheet to price the week's parcels and flag anything odd. Build it in four steps.
- Decode the service. In a spare column, turn the code into a name:
Fill down. You get Express, Standard, Economy, Standard, Express and Check code. Row 7 is the one to chase.
- Price each parcel. In G2 put the cost per kilo rule:
Fill down to get 7.2, 17.5, 36, 120, 55.8 and 0.
- Catch the unpriced parcels. A zero cost means the code was not recognised. Count the zeros and turn the count into a warning:
One parcel is priced at zero, so the cell shows Fix service codes.
- Check the weekly spend. Add the costs and compare them with the budget:
The costs add up to 236.5, so the cell shows Over budget.
Four formulas, and the only place a code lives is inside a SWITCH. When EXP gets a new rate, you change one number.
Practice the SWITCH function
SWITCH is a function you only learn by typing it, because the pair-counting is easy to read and easy to get wrong. Open Practice Lesson 65 and type the formula yourself. Start with the one-pair version and add pairs one at a time, the way the lesson does, then add the default. For a refresher on how Excel decides what is TRUE or FALSE, see True & False. For the sibling function with ranges, read the IFS guide.
FAQ
What does the SWITCH function do in Excel?
SWITCH compares one value, called the expression, with a list of values and returns the result beside the first match. Excel works out the expression once. If nothing matches, it returns the optional default, or #N/A when there is no default. It was added in Excel 2019 as a tidier alternative to nested IF.
How do I add a default value to SWITCH?
Put one extra argument at the end of the list, with no partner. In =SWITCH(E6,1,"Packed",2,"In transit","Unknown code"), the final "Unknown code" is the default. Excel returns it when the expression matches none of the values. Without it, an unmatched value returns #N/A.
Can SWITCH use greater than or less than?
Not directly, because SWITCH only tests equality. The workaround is SWITCH(TRUE, ...) with a test as each value, for example SWITCH(TRUE,D2<=1,"Small",D2<=5,"Medium","Large"). For many ranges, IFS is cleaner and reads in the same order.
Is SWITCH case sensitive?
No. Text matching ignores capital letters, so "eco", "Eco" and "ECO" all match "ECO". It does care about spaces and about text versus numbers. A code with a trailing space will not match, and the text "1" will not match the number 1. Use TRIM and check your column types.
What is the difference between SWITCH and IFS?
SWITCH matches one expression against exact values. IFS runs a list of separate tests, so it can handle ranges, AND, OR and different cells. IFS has no default argument, so you add TRUE, "default" at the end. SWITCH has a built-in default. Both need Excel 2019 or Microsoft 365.
How many values can SWITCH handle?
Microsoft lists up to 126 pairs of value and result in one SWITCH, plus an optional default. In practice a list that long belongs in a lookup table on a sheet, where you can edit it without touching the formula.
Why does my SWITCH formula return #N/A?
No value matched and you have no default. First check for a type mismatch (text "1" versus number 1) or a trailing space. Then add a default as the final argument so unmatched values show a message instead of #N/A.
Does SWITCH work in Excel 2016?
Only with a Microsoft 365 subscription. The perpetual Excel 2016, Excel 2013 and earlier do not have SWITCH, and a workbook that contains it shows #NAME? there. Excel 2019, 2021, 2024, Microsoft 365, Excel for the web and the Mac editions of those releases all include it.
Sources
Keep going
Guides people read next.

WEEKDAY Function in Excel: Syntax, Examples and Day Names
Learn how the Excel WEEKDAY function works, which return_type to pick, how to get day names, flag weekends and fix errors, with copy-ready formulas.
15 min
CHOOSECOLS Function in Excel: Syntax, Examples, Fixes
Learn how the Excel CHOOSECOLS function works, with CHOOSEROWS too: syntax, negative indexes, FILTER combos, version support and fixes for #VALUE! and #SPILL!.
16 minExcel FIND Function: Syntax, Examples and Fixes
Use the Excel FIND function to get a character's position, split text at @ or hyphens, find the second match, and fix #VALUE! errors.
16 min