Back to functions
Logical2026-03-181 related article

SWITCH Function in Excel

Match an expression against a list of values and return the result for the first match.

Syntax

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

Arguments

expression

Required

The value or formula to match against.

value1

Required

The first value to compare with the expression.

result1

Required

The result returned when expression matches value1.

default

Optional

The result returned when no values match. If omitted and nothing matches, SWITCH returns

What it returns

Returns the result paired with the first matching value, or the default if no match is found.

What SWITCH does

SWITCH compares one expression against a list of values and returns the result for the first match. It is a cleaner alternative to nested IF when you are matching against specific values rather than ranges.

When combined with TRUE as the expression, SWITCH can also evaluate conditions, making it behave like IFS.

Practical examples

Map a department code to a name

=SWITCH(A2,"HR","Human Resources","ENG","Engineering","MKT","Marketing","Unknown")

Each code is matched exactly. The last argument without a pair is the default.

Use SWITCH with TRUE for range-based logic

=SWITCH(TRUE,A2<10,"XS",A2<20,"S",A2<30,"M",A2<40,"L","XL")

This pattern evaluates conditions in order, similar to IFS.

Common mistakes and notes

SWITCH matches exact values

Unlike IFS, SWITCH compares the expression against specific values. For greater-than or less-than logic, use the SWITCH(TRUE, ...) pattern or use IFS instead.

Maximum of 126 pairs

SWITCH supports up to 126 value/result pairs. In practice, if you need that many branches, a lookup table with VLOOKUP or XLOOKUP is usually better.

Availability

SWITCH is available in Excel 365, Excel 2021, and Excel 2019. It is not available in Excel 2016 or earlier.

Related functions

Related articles

Deep dives, troubleshooting guides, and practical examples that use SWITCH.

Official documentation