---
title: "SWITCH function in Excel: syntax and examples | ExcelSavvy"
description: "How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs."
canonical_url: "https://excelsavvy.com/functions/switch"
meta:
  "og:description": "How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs."
  "og:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "SWITCH function in Excel: syntax and examples | ExcelSavvy"
  "twitter:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png"
---

> Index of every page on this site: [llms.txt](https://excelsavvy.com/llms.txt)

# **The SWITCH function**

Compares one value against a list and returns the result for the first match, with an optional default at the end.

=

SWITCH(

## **How to use SWITCH**

SWITCH is a small lookup you write inside a single cell, like a coat check: you hand over a ticket and get the coat that belongs to it. You name the value once, then list pairs of "if it equals this, return that", and finish with an optional default for the tickets nobody recognizes.

`**=SWITCH(A2,"DK","Denmark","SE","Sweden","Other")**` compares the code in A2 with "DK", then "SE", and returns the matching country, or Other when neither fits. Reach for it when a cell can only hold a handful of exact values: country codes, status numbers, weekday numbers, department abbreviations or payment methods.

Compared with IF, you type the cell once instead of in every test, so the formula is shorter and harder to get wrong. SWITCH only tests for equality, so for limits such as "60 or more" use IFS. You can still do limits by switching on TRUE: `**=SWITCH(TRUE,A2>=90,"High",A2>=60,"Mid","Low")**`. If you have many codes, or they change often, put them in a table and use VLOOKUP or XLOOKUP. Then you edit the list instead of the formula.

## **Syntax**

```
SWITCH(expression, value1, result1, [value2, result2], ..., [default])
```

<dl><dt>**expression **</dt>
<dd>The value to compare.</dd>
<dt>**value1, result1 **</dt>
<dd>A value to match and the result to return for it.</dd>
<dt>**default **(optional)</dt>
<dd>What to return when nothing matches. Without it SWITCH returns #N/A.</dd></dl>

## **Examples**

C1`=SWITCH(<sup>1</sup>A2,<sup>2</sup>"DK",<sup>3</sup>"Denmark",<sup>4</sup>"SE",<sup>5</sup>"Sweden",<sup>6</sup>"Other")`

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Code |  | **Denmark** |
| 2 | DK |  | |

**In plain words:** Look at <sup>1</sup>the code in A2: <sup>2</sup>if it is DK, <sup>3</sup>show Denmark; <sup>4</sup>if it is SE, <sup>5</sup>show Sweden; <sup>6</sup>otherwise show Other.

C1=SWITCH(A2,"NO","Norway","Other")

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Code |  | **Other** |
| 2 | DK |  | |

## **Common SWITCH mistakes**

- SWITCH returns #N/A

  Nothing matched and there is no default. Add one as the last argument: `**=SWITCH(A2,"NO","Norway","Other")**`. If the code should match but does not, look for extra spaces and wrap the cell in TRIM, as in `**=SWITCH(TRIM(A2),"DK","Denmark","Other")**`.
- The number 1 never matches "1"

  A number in quotes is text, so `**=SWITCH(A2,"1","Mon","2","Tue")**` fails when A2 holds the number 1. Write the values without quotes: `**=SWITCH(A2,1,"Mon",2,"Tue","Other")**`.
- SWITCH with ">=90" does not work

  SWITCH compares the value with what you write, so ">=90" is just the text ">=90". For limits, switch on TRUE, as in `**=SWITCH(TRUE,A2>=90,"High","Low")**`, or use IFS.

## **Read the guide**

- [**Excel IF formulas: from one condition to many**](https://excelsavvy.com/learn/excel-if-function)

## **Questions**

<details>

<summary>

### Does SWITCH work in older versions of Excel?

</summary>

SWITCH is available in Excel 2019, Excel 2021, Microsoft 365 and Google Sheets. Excel 2016 and earlier do not have it and show #NAME?. There you can use CHOOSE for numbers or nested IFs for text.

</details>

<details>

<summary>

### What is the difference between SWITCH and IFS?

</summary>

SWITCH checks one value for equality against a list, and you write the value once. IFS takes a full test for every line, so it can handle limits like A2&gt;=90, but you repeat the cell in each test.

</details>

<details>

<summary>

### Can SWITCH handle ranges like "between 50 and 80"?

</summary>

Not directly, but you can switch on TRUE and put the tests in the value slots, =SWITCH(TRUE,A2&lt;50,"Low",A2&lt;80,"Mid","High"). The first test that is TRUE wins, so order them from the strictest.

</details>

## **Related functions**

- [**IFS**](https://excelsavvy.com/functions/ifs)
- [**IF**](https://excelsavvy.com/functions/if)
- [**CHOOSE**](https://excelsavvy.com/functions/choose)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://excelsavvy.com/#identity","@type":"Organization","name":"ExcelSavvy","url":"https://excelsavvy.com/","logo":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/#website","@type":"WebSite","inLanguage":"en-US","name":"ExcelSavvy","url":"https://excelsavvy.com/","alternateName":["Excel Savvy","ExcelSavvy.com","PracticeExcel","Practice Excel Online"],"publisher":{"@id":"https://excelsavvy.com/#identity"},"workTranslation":[{"@id":"https://excelopgaver.dk/#website"},{"@id":"https://excelpraxis.de/#website"}]},{"@id":"https://excelsavvy.com/functions/switch#webpage","dateModified":"2026-11-16","description":"How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs.","name":"SWITCH function in Excel: syntax and examples","url":"https://excelsavvy.com/functions/switch","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://excelsavvy.com/functions/switch#breadcrumb"},"isPartOf":{"@id":"https://excelsavvy.com/#website"},"mainEntity":[{"@id":"https://excelsavvy.com/functions/switch#/schema/question/1"},{"@id":"https://excelsavvy.com/functions/switch#/schema/question/2"},{"@id":"https://excelsavvy.com/functions/switch#/schema/question/3"}],"potentialAction":[{"@type":"ReadAction","target":["https://excelsavvy.com/functions/switch"]}],"primaryImageOfPage":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/functions/switch#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://excelsavvy.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://excelsavvy.com/functions","position":2},{"@type":"ListItem","name":"SWITCH function in Excel: syntax and examples","position":3}]},{"@id":"https://excelsavvy.com/functions/switch#article","dateModified":"2026-11-16","description":"How to use SWITCH in Excel 365 and Google Sheets: map codes to names without nesting IFs.","headline":"SWITCH function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://excelsavvy.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png","@type":["Article","TechArticle"],"author":{"@id":"https://excelsavvy.com/#identity"},"image":{"@id":"https://excelsavvy.com/#/schema/image/1"},"isPartOf":{"@id":"https://excelsavvy.com/functions/switch#webpage"},"mainEntityOfPage":{"@id":"https://excelsavvy.com/functions/switch#webpage"},"publisher":{"@id":"https://excelsavvy.com/#identity"}},{"@id":"https://excelsavvy.com/functions/switch#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"Does SWITCH work in older versions of Excel?","acceptedAnswer":{"@type":"Answer","text":"SWITCH is available in Excel 2019, Excel 2021, Microsoft 365 and Google Sheets. Excel 2016 and earlier do not have it and show #NAME?. There you can use CHOOSE for numbers or nested IFs for text."}},{"@id":"https://excelsavvy.com/functions/switch#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"What is the difference between SWITCH and IFS?","acceptedAnswer":{"@type":"Answer","text":"SWITCH checks one value for equality against a list, and you write the value once. IFS takes a full test for every line, so it can handle limits like A2>=90, but you repeat the cell in each test."}},{"@id":"https://excelsavvy.com/functions/switch#/schema/question/3","@type":"Question","inLanguage":"en-US","name":"Can SWITCH handle ranges like \"between 50 and 80\"?","acceptedAnswer":{"@type":"Answer","text":"Not directly, but you can switch on TRUE and put the tests in the value slots, =SWITCH(TRUE,A2\u003C50,\"Low\",A2\u003C80,\"Mid\",\"High\"). The first test that is TRUE wins, so order them from the strictest."}},{"@id":"https://excelsavvy.com/#logo","@type":"ImageObject","caption":"ExcelSavvy","contentUrl":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3","inLanguage":"en-US","url":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3"},{"@id":"https://excelsavvy.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://excelsavvy.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png","inLanguage":"en-US","url":"https://excelsavvy.com/_og/d/c_Page%2Ctitle_~U1dJVENIIGZ1bmN0aW9uIGluIEV4Y2VsOiBzeW50YXggYW5kIGV4YW1wbGVz%2Cdescription_~SG93IHRvIHVzZSBTV0lUQ0ggaW4gRXhjZWwgMzY1IGFuZCBHb29nbGUgU2hlZXRzOiBtYXAgY29kZXMgdG8gbmFtZXMgd2l0aG91dCBuZXN0aW5nIElGcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~U1dJVENIKGV4cHJlc3Npb24sIHZhbHVlMSwgcmVzdWx0MSwgW3ZhbHVlMiwgcmVzdWx0Ml0sIC4uLiwgW2RlZmF1bHRdKQ%2Cp_Ii9mdW5jdGlvbnMvc3dpdGNoIg%2Cs_vYG4qDujfKU_JndN.png"}]}
```

## Sitemap

See the full [sitemap](https://excelsavvy.com/sitemap.md) for all pages.
