Google Sheets function · Array
WRAPROWS in Google Sheets: syntax and examples
WRAPROWS takes a single row or column and cuts it into rows of wrap_count values each. It turns a long list into a grid.
Syntax
WRAPROWS(range, wrap_count, [pad_with])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
range | range | yes | A single row or column of values to reshape. |
wrap_count | number | yes | How many values go on each new row. |
pad_with | any | no | What fills the last row if values run out. Default is #N/A. |
Examples
The examples use this table, starting in A1:
| 10 |
| 20 |
| 30 |
| 40 |
| 50 |
| 60 |
=WRAPROWS(A1:A6, 2)Result:
| 10 | 20 |
| 30 | 40 |
| 50 | 60 |
Six values in a column become three rows of two.
Run in a Google Sheet (English US locale) on .
=WRAPROWS(A1:A6, 3)Result:
| 10 | 20 | 30 |
| 40 | 50 | 60 |
The same list as two rows of three. Values fill each row left to right.
Run in a Google Sheet (English US locale) on .
=WRAPROWS(A1:A5, 2, "-")Result:
| 10 | 20 |
| 30 | 40 |
| 50 | - |
Five values do not fill the last row, so pad_with supplies a dash.
Run in a Google Sheet (English US locale) on .
=WRAPROWS(A1:A5, 2, 0)Result:
| 10 | 20 |
| 30 | 40 |
| 50 | 0 |
Padding with 0 keeps the block numeric.
Run in a Google Sheet (English US locale) on .
=WRAPROWS(TRANSPOSE(A1:A6), 3)Result:
| 10 | 20 | 30 |
| 40 | 50 | 60 |
A row works as input too. Here TRANSPOSE turns the column into a row first.
Run in a Google Sheet (English US locale) on .
Common errors
- If the values do not fill the last row, the free spots show #N/A. Add pad_with, such as "-" or 0, to fill them.
- A wrap_count of 0 returns #NUM!.
- A wrap_count larger than the list returns one row with that many columns, padded with #N/A.
Compared with Excel
Same syntax in Excel.