Premium Google Sheets drill · Sheets scenarios
Clean a name column
Practice a Google Sheets cleanup column that uses ARRAYFORMULA, TRIM, and REGEXREPLACE to fix spaced names.
A2:A4 are names with extra spaces. In Sheets, TRIM removes spaces at the ends and leaves spaces between words alone.
In C2, use ARRAYFORMULA to trim each name and then replace runs of spaces with a single space.
Dataset
Starter sheet. Cells marked formula are where the formula goes.
| Row | A | B | C |
|---|---|---|---|
| 1 | Raw name | Clean name | |
| 2 | Ada Lovelace | Formula goes in C2. formula | |
| 3 | Grace Hopper | ||
| 4 | Alan Turing |
Hint
REGEXREPLACE can turn one or more spaces into one space. The pattern is a space followed by +.
Explanation
TRIM drops the spaces around Ada, and REGEXREPLACE collapses the double spaces inside the names. Grace Hopper is already a single space, so it stays as it is.
The interactive sheet and a worked solution are part of Formula Drills Premium. The instructions and starter data on this page are the full problem.