ShareYourGroupShareYourGroupExcel Formulas

Logical functions

SWITCH function in Excel

SWITCH compares one value with a list of possible values and returns the result that goes with the first match.

SWITCH turns one set of values into another: a code into a name, a region into an office, a status letter into a word. It does what a chain of IF(A2="x", ..., IF(A2="y", ... does, without repeating the cell reference in every step. It is available in Excel 2019, Excel 2021 and Microsoft 365.

Syntax

=SWITCH(expression, value1, result1, [value2, result2], ..., [default])
ArgumentWhat it is
expressionThe value to test, usually a cell.
value1, result1A value to compare with, and what to return if it matches.
value2, result2, ...More pairs.
defaultWhat to return when nothing matches. It is the last argument and has no partner.

Examples

Each result below is what Excel itself showed for the formula on the sample sheet.

Sample sheet: Twelve sales made by four salespeople in three regions.
ABCDEF
1DateSalespersonRegionProductUnitsAmount
205-Jan-2026AshaNorthNotebook201200
312-Jan-2026RaviSouthPen50500
420-Jan-2026MeenaNorthBag43000
502-Feb-2026AshaEastPen30300
614-Feb-2026KabirSouthNotebook15900
728-Feb-2026RaviNorthBag21500
803-Mar-2026MeenaEastNotebook402400
915-Mar-2026AshaNorthBag32250
1022-Mar-2026KabirSouthPen60600
1101-Apr-2026RaviEastNotebook251500
1218-Apr-2026MeenaNorthPen80800
1306-May-2026AshaSouthBag53750

How it works

SWITCH takes the expression, usually a single cell, and compares it with each value in turn. At the first exact match it returns the result paired with that value. If nothing matches, it returns the default, which is the last argument when the number of arguments after the expression is odd.

Compare the two ways of writing the same thing:

The cell is named once, and there is one closing bracket.

Always give a default

Without a default, a value that is not on the list produces #N/A, as in the fourth example. Sometimes that is right: an unknown code should be noticed. More often a default such as "Other" or "Check" is kinder.

SWITCH matches exactly

SWITCH tests for equality only. It cannot say "greater than 50" in the ordinary way. For ranges of numbers use IFS, or the SWITCH(TRUE, ...) trick in the last example, where each "value" is a condition and the first one that equals TRUE wins. Many people find IFS clearer for that job.

Matching ignores capital and small letters, so "north" matches "North". It does not ignore spaces.

SWITCH, IFS, CHOOSE or a lookup?

You haveUse
one cell to compare with a few fixed valuesSWITCH
different conditions, such as number rangesIFS
a number 1, 2, 3 that picks from a listCHOOSE
more than six or seven pairs, or pairs that changea table and XLOOKUP or VLOOKUP

The last row matters. A formula with fifteen pairs typed into it is a small database hidden where nobody can see or edit it. Put the pairs in two columns on a sheet and look them up.

Common mistakes

In Google Sheets

SWITCH is available in Google Sheets with the same arguments.

Related functions

Every result on this page was calculated in Microsoft Excel (version 16.0, build 20326) on 12 November 2026, not typed by hand.

This is an independent help site. It is not connected with or approved by Microsoft. Excel and Microsoft 365 are trademarks of Microsoft Corporation, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.