Templates, guides & honest tool reviews for small business

Sunday, November 29, 2026

SWITCH Function in Excel: Replace Nested IF with Clear Examples

SWITCH function in Excel with examples
Illustration: SWITCH function in Excel

The SWITCH function in Excel compares one value against a list of options and returns the result for the first match. The syntax is =SWITCH(expression, value1, result1, [value2, result2, ...], [default]). It replaces long nested IF formulas when you test one cell against several exact values. SWITCH is available in Excel 2019 and later and in Excel 365. It is not in Excel 2016 or earlier. The sample data is made up.

SWITCH syntax

  • expression is the value to test, usually a cell.
  • value1, value2 are the values to compare with.
  • result1, result2 are what to return when the matching value is found.
  • default is optional. It is returned when nothing matches. It is the last argument and has no value in front of it.
SWITCH function syntax in Excel
Expression, pairs, default (illustration).

A simple example

Turn a status code in A2 into a word:

=SWITCH(A2, 1, "New", 2, "In progress", 3, "Done", "Unknown")

If A2 is 2 the result is "In progress". If A2 is 9, nothing matches and the result is "Unknown". Without a default, an unmatched value returns the #N/A error.

SWITCH turns a status code into a word in Excel
Made-up codes (illustration).

Replace a nested IF

The same task with IF needs three levels: =IF(A2=1,"New",IF(A2=2,"In progress",IF(A2=3,"Done","Unknown"))). SWITCH is shorter and easier to read. Our guide to the nested IF formula shows the older style.

Convert a number to a day name

=SWITCH(WEEKDAY(B2), 1, "Sunday", 2, "Monday", 3, "Tuesday", 4, "Wednesday", 5, "Thursday", 6, "Friday", 7, "Saturday")

WEEKDAY returns 1 for Sunday by default, so the list above matches. For a simpler way to show a day name, the TEXT function with the format "dddd" does the same.

SWITCH with TRUE for ranges

SWITCH only compares exact values, so it cannot test "greater than 80" directly. A common trick is to use TRUE as the expression and put the conditions in the value positions:

=SWITCH(TRUE, B2>=90, "A", B2>=80, "B", B2>=70, "C", "F")

Excel checks each condition in order and stops at the first one that is TRUE. Put the highest limit first. For this job, IFS is also an option, and a lookup table with approximate match works well if the list is long.

SWITCH with TRUE for grade ranges in Excel
Highest limit first (illustration).

SWITCH or IFS?

  • Use SWITCH when you test one cell against exact values.
  • Use IFS when each test is a different condition, such as ranges.
  • Use a lookup table when the list is long or changes often. Our XLOOKUP guide shows how.
SWITCH versus IFS versus a lookup table in Excel
Pick by the test (illustration).

Combine SWITCH with other tests

To check two things, use AND or OR inside the TRUE form. See the IF formula with AND and OR for the pattern.

Fix common errors

  • #N/A. No value matched and you gave no default. Add one at the end.
  • #NAME? Your Excel version does not have SWITCH, or the name is misspelled.
  • Text not matching. Spaces or different spelling. SWITCH ignores upper and lower case but not extra spaces. Clean the cell with TRIM first.
  • A default treated as a pair. If you have an even number of arguments after the expression, Excel reads the last one as a value with no result. Count the arguments.

Questions and answers

Is SWITCH case sensitive?

Test it on your data. In many cases Excel text comparisons ignore case, but check before you rely on it.

How many pairs can SWITCH have?

Microsoft documents up to 126 value and result pairs.

Does SWITCH exist in Google Sheets?

Yes. Google Sheets has a SWITCH function with the same idea. For several conditions in Sheets, see our IF with multiple conditions guide.

Can SWITCH return a formula?

Yes. A result can be a calculation, such as B2*0.1.

العربية