Sub topic 3
Split combined values with Split text to columns
This chapter assumes you can select ranges, enter formulas, and that you have already copied your raw data to a separate sheet. A combined value such as "Doe, Jane" sits in one cell, so you cannot sort or count by its parts until you split it.
Split with the menu tool
- Select the column, for example A2:A.
- Choose Data > Split text to columns.
- Sheets guesses a separator. Confirm it matches your data, or choose Custom and enter ", ".
- Sheets writes the parts into the columns to the right as static values.
Make sure the columns to the right are empty. The tool overwrites any existing data there.
Split with a formula: the SPLIT function
The menu tool writes static values. SPLIT writes a live result that updates when the source changes. Its syntax is SPLIT(text, delimiter, [splitbyeach], [removeemptytext]).
=SPLIT(A2, ", ", FALSE)With splitbyeach set to FALSE, the full delimiter ", " counts as one separator. With the default TRUE, every character in the delimiter splits the text, so "Doe, Jane Ann" would also split on the space and return three parts. If cells to the right are not empty, SPLIT returns a #REF! error.
Strip unwanted characters with REGEXREPLACE
REGEXREPLACE(text, regular_expression, replacement) replaces every match of a pattern. The pattern "[^0-9]" matches any character that is not a digit.
=REGEXREPLACE(A2, "[^0-9]", "")This turns "(555) 010-1234" into "5550101234".
Combine trim, case, dedupe, and split into one repeatable pipeline
Run the steps in a fixed order: clean first, then split, then pattern cleanup, then deduplicate. Put the cleaning step in column C:
=ARRAYFORMULA(PROPER(TRIM(CLEAN(SUBSTITUTE(A2:A, CHAR(160), " ")))))Put the split in D2 and copy it down, then apply REGEXREPLACE in E2 to strip stray characters. Use UNIQUE on the finished columns when you need distinct rows.
Check the cleaned data before you trust it
Run these checks on the cleaned columns. Each one should return the expected result.
| Check | Formula | Expected result |
|---|---|---|
| Extra spaces left in column C | =SUMPRODUCT(--(LEN(C2:C)<>LEN(TRIM(C2:C)))) | 0 |
| Non-digit characters left in a phone column | =SUMPRODUCT(--REGEXMATCH(F2:F, "[^0-9]")) | 0 |
Keep the raw column A until every check passes.
Exercise
Cell A2 contains "Smith, John". Which formula returns only "Smith" in a single cell, without spilling into other cells?
Show answer
=INDEX(SPLIT(A2, ", ", FALSE), 1) returns the first part, "Smith". SPLIT returns both parts as an array, and INDEX picks position 1.