Sub topic 4
Splitting a Whole Column and Turning Columns into Rows
This chapter assumes you can enter formulas, reference cells and ranges, and use basic functions such as TRIM and IFERROR. You should also know that a text value is a string and that text arguments use double quotes.
A formula can return more than one value in Google Sheets. These results form an array. When an array formula returns several values, Sheets places them in nearby empty cells automatically. This behavior is called spilling.
Split one cell into several columns
Suppose column A contains comma-separated tags:
| A |
|---|
| red,large,round |
| blue,small,square |
| green,medium,triangle |
To split the first row into separate columns, enter this formula in B2:
=SPLIT(A2, ",")The result spills horizontally:
| A | B | C | D |
|---|---|---|---|
| red,large,round | red | large | round |
SPLIT returns one result for each piece of text. In this example, the comma is the delimiter, which is the character that separates the pieces.
A spilled result occupies multiple cells even though you entered only one formula. The formula remains in B2, while C2 and D2 contain the values produced by that formula.
Split a whole range with ARRAYFORMULA
Copying a formula down works for a small list, but ARRAYFORMULA lets one formula process a range:
=ARRAYFORMULA(SPLIT(A2:A10, ","))Enter this formula in B2. Sheets processes each input row and spills the pieces across columns. The first input row produces results in row 2, the second input row produces results in row 3, and so on.
The input range and the output area must be planned together. If each row contains up to three tags, reserve enough empty columns for three results. A row with fewer tags may not fill every output column.
The output is still an array, but it has two dimensions:
- The first dimension follows the rows in
A2:A10. - The second dimension follows the pieces created by
SPLIT.
This model helps explain why a single formula can fill a rectangle of cells.
Turn split columns into rows with TRANSPOSE
SPLIT normally returns values across a row. Use TRANSPOSE when you need those values down a column:
=TRANSPOSE(SPLIT(A2, ","))For red,large,round, the result is:
| B |
|---|
| red |
| large |
| round |
TRANSPOSE exchanges rows and columns. A horizontal array becomes vertical, and a vertical array becomes horizontal.
This is useful when a later calculation expects one item per row, such as a lookup, filter, or summary. It can also make a list easier to read when the original cell contains a long sequence of values.
Choose the correct layout
Use SPLIT alone when one cell should produce columns. Use ARRAYFORMULA(SPLIT(...)) when many input rows need the same operation. Add TRANSPOSE when the output from one cell should run downward.
Before entering the formula, check:
- Where the output should begin.
- How many columns or rows the result may need.
- Whether those cells are empty.
- Whether the source values use the same delimiter consistently.
Whitespace is part of the result. For example, splitting red, large with a comma can produce red and large. You can clean the pieces with TRIM:
=ARRAYFORMULA(TRIM(SPLIT(A2:A10, ",")))TRIM removes extra spaces from each spilled value.
Exercise
Which formula splits every value in A2:A10 at commas and returns the pieces across each row?
Show answer
=ARRAYFORMULA(SPLIT(A2:A10, ","))