Text cleanup formulas
To split text, use FIND to locate the separator and LEFT, MID or RIGHT to cut around it. Clean what is left with TRIM and SUBSTITUTE, and join pieces back with CONCAT or TEXTJOIN.
Last updated 23 November 2026
| A | B | |
|---|---|---|
| 1 | Code | |
| 2 | GHIJ-4821 |
In B2, write =LEFT(A2,FIND("-",A2)-1) and it shows GHIJ.
Cutting text apart
LEFT(text, n) and RIGHT(text, n) take n characters from either end. MID(text, start, n) takes n characters from a position, where 1 is the first character. LEN gives the length.
When the pieces vary in length, find the cut with FIND: the prefix before a dash is LEFT(A2, FIND("-",A2)-1), and everything after it is MID(A2, FIND("-",A2)+1, LEN(A2)).
Tidying
TRIM removes spaces at both ends and reduces runs of spaces to one. UPPER, LOWER and PROPER change case. SUBSTITUTE(text, old, new) replaces text, and an empty new text deletes the old one.
Numbers that arrive as text are ignored by SUM. VALUE turns them into numbers, and TRIM first if there are stray spaces: VALUE(TRIM(A2)).
Joining
CONCAT joins its arguments in order. TEXTJOIN(delimiter, ignore_empty, range) joins a whole range with a separator and can skip empty cells, which avoids doubled commas.
Practise it
Module 5, Text cleanup, has 20 tasks on this, each checked on hidden data: open module 5. You can also try formulas in the sandbox.