SWITCH: one of several values

1 / 5

Each store has a one-letter region code. Turn the codes into region names in column C.

keyboard Typing formulas is easiest on a computer with a keyboard.

A1
ABCD
1StoreRegion codeRegion
2Store 539NE
3Store 225N
4Store 463E
5Store 322E
6Store 239N
7Store 540W
8Store 160S
9Store 455W
10
11
12
13
codes
names
Type to enter a value or a formula starting with =. F2 edits, F4 adds $ to a reference.
Study notes

How SWITCH works

  • What does SWITCH do?

    SWITCH looks at one value and compares it with a list. When it finds a match, it returns the result paired with it:

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

  • How do you read it?

    • First, the value to check: B2.
    • Then pairs: a value to match, and the result for it. "N" gives "North", "S" gives "South".
    • Last, on its own, the default: what to show when nothing matches.
  • What if there is no default?

    A value that matches nothing gives #N/A. Adding a default such as "Unknown" catches typos and new codes.

  • Why not nested IFs?

    =IF(B2="N","North",IF(B2="S","South",...)) works, but every extra code adds another IF and another bracket. SWITCH names B2 once and lists the pairs, so it is easier to read and to extend. Use IFS instead when the questions are different, such as B2>=70, not one value matched against a list.

  • Does case matter?

    No. "n" matches "N", just as it does with =.

Know someone fighting with a spreadsheet? Send them this page.