Splitting with LEFT, MID and FIND

1 / 5

Each product code is a category, a dash, then a colour. Pull the colour out into column B.

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

A1
ABC
1Product codeColour
2SWEATER-RED
3HOODIE-ORANGE
4SHIRT-NAVY
5BAG-RED
6HAT-NAVY
7GLOVES-BLUE
8JACKET-ORANGE
9SWEATER-GREY
10
11
12
13
codes
colour
Type to enter a value or a formula starting with =. F2 edits, F4 adds $ to a reference.
Study notes

How LEFT and MID and RIGHT and FIND works

  • How do LEFT, RIGHT and MID work?

    • =LEFT(A2,2) takes the first 2 characters.
    • =RIGHT(A2,3) takes the last 3.
    • =MID(A2,4,2) takes 2 characters, starting at character 4.
  • What if the parts change length?

    In codes like CAP-BLUE and JACKET-RED the parts have different lengths, so a fixed number won't work for every row. FIND gives the position of a character, such as the dash: =FIND("-",A2).

  • How do you get the part before the dash?

    It is the dash's position minus 1 characters long:

    =LEFT(A2,FIND("-",A2)-1)

  • How do you get the part after the dash?

    It starts one character after the dash. MID stops at the end of the text, so asking for more characters than are left is fine:

    =MID(A2,FIND("-",A2)+1,20)

    Newer Excel also has TEXTBEFORE and TEXTAFTER, which do each in one step: =TEXTAFTER(A2,"-").

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