Excel SWITCH function

Compares a value with a list of options and returns the matching result. In Spanish Excel it is called CAMBIAR.

Syntax

English Excel

=SWITCH(expression, value1, result1, [default_or_value2, result2], …)

Spanish Excel (Mexico)

=CAMBIAR(expresión, valor1, resultado1, [predeterminado_o_valor2, resultado2], …)

Spanish Excel (Spain, Latin America)

=CAMBIAR(expresión; valor1; resultado1; [predeterminado_o_valor2; resultado2]; …)

ArgumentWhat it is
expressionThe value to compare.
value1The first option.
result1What it returns on a match.
default_or_value2, result2optionalMore pairs; a final unpaired value is the default.

Example

SWITCH(value, option1, result1, option2, result2…, default) compares a value with a list of options. It is ideal for turning codes into names.

=SWITCH(B2,"N","North","S","South","Central")

Common mistake

It only checks equality. For ranges (greater than, less than) use IFS.

About Ads

This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.

Advertising
Loading ad...

Ads help us keep WebHerramientas free for everyone

Practice SWITCH

Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons

SWITCH

SWITCH(value, option1, result1, option2, result2…, default) compares a value with a list of options. It is ideal for turning codes into names.

Example=SWITCH(B2,"N","Norte","S","Sur","Centro")CAMBIAR = SWITCH

In C2, translate the code: N is "North", S is "South" and anything else is "Central".

C2
ABCD
1OrderCodeRegion
2P-01N
3P-02S
4P-03C
5P-04N
6P-05S
7

Tip: while typing, click a cell or drag across several to insert their reference.

Frequently asked questions

What is SWITCH called in Spanish?
In Spanish Excel it is CAMBIAR. The formula =SWITCH(B2,"N","North","S","South","Central") is written =CAMBIAR(B2;"N";"Norte";"S";"Sur";"Centro") (or with commas in Mexico).
Why does SWITCH use semicolons in some Excel versions?
It depends on regional settings. Where the comma is the decimal mark (Spain, much of South America), Excel separates arguments with semicolons. English Excel and Mexican Spanish Excel use commas.
What is the most common SWITCH mistake?
It only checks equality. For ranges (greater than, less than) use IFS.