# How to use SWITCH instead of nested IFs in Excel

List each value and its result in pairs, with a default at the end: =SWITCH(B2,"N","North","S","South","E","East","W","West","Unknown").

**Excel:** `=SWITCH(B2,"N","North","S","South","E","East","W","West","Unknown")` (Excel 2019 and later, including Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C |
| --- | --- | --- |
| Rep | Code | Region |
| Ana | N |  |
| Ben | S |  |
| Cara | E |  |
| Dev | W |  |
| Eli | S |  |
| Fay | X |  |

Formula in C2, filled to C7: `=SWITCH(B2,"N","North","S","South","E","East","W","West","Unknown")`

Result: North; South; East; West; South; Unknown

## How it works

SWITCH compares the first argument with each value in turn and returns the result paired with the first match. The final lone argument is the default, used when nothing matches, as for Fay's "X". The cell is written once instead of once per IF.

## Other ways

- `=IF(B2="N","North",IF(B2="S","South",IF(B2="E","East",IF(B2="W","West","Unknown"))))`: The nested IF that SWITCH replaces. Works in every version, including Excel 2016.
- `=XLOOKUP(B2,{"N","S","E","W"},{"North","South","East","West"},"Unknown")`: A lookup on two array constants. Move them into cells and it becomes a table you can edit.

## Common mistakes

- SWITCH only tests for equality. For ranges like "90 and above" use IFS, or `SWITCH(TRUE,B2>=90,"A",B2>=80,"B","C")`.
- Without a default, a value that matches nothing returns #N/A.
- SWITCH needs Excel 2019 or later (or Google Sheets). Excel 2016 shows #NAME?.

## Questions

**Is SWITCH case-sensitive?**

No. "n" matches "N", just as with =.

**How many pairs can SWITCH take?**

Up to 126 value and result pairs. Long before that, a lookup table is easier to maintain.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/switch-instead-of-nested-if
