WRAPROWS folds a single list into a grid. Give it twelve months in a column and a wrap count of 4 and you get three rows of four. It fills each row from left to right before starting the next, the way you read a page.
The arguments
- vector is the list to wrap. It must be one column or one row. Pass a block of several rows and columns, and WRAPROWS returns
#VALUE!. Use TOCOL first if you need to flatten a block. - wrap_count is how many values go in each row. The number of rows is worked out for you: 12 values with a wrap count of 4 gives 3 rows.
- pad_with fills the gap when the last row isn't full.
Uneven lists and padding
Seven items with a wrap count of 3 make two full rows and one with a single item. By default the missing two cells show #N/A, which stands out and can break a total. Give a pad value to replace it: =WRAPROWS(A2:A8,3,"") leaves the cells blank-looking, and =WRAPROWS(A2:A8,3,0) fills them with zeros. The padding value goes in the last row only.
Where it helps
- Layouts. Turn a list of seat holders, products or months into a block that fits a page or a dashboard.
- Calendars and quarters. Twelve months wrap into four columns, or into three rows of four with
wrap_count 4. - Reshaping imports. Data that arrives as one long column, with a fixed number of fields per record, can be wrapped into one record per row. If each record has 5 fields,
=WRAPROWS(A2:A101,5) returns 20 rows of 5 columns.
WRAPROWS or WRAPCOLS
WRAPCOLS does the same but fills down each column first. Use WRAPROWS when the list should read like text, left to right. Use WRAPCOLS when it should read like a newspaper, top to bottom.
Combining it with other functions
WRAPROWS works on the output of other dynamic array functions. =WRAPROWS(SORT(A2:A13),4) sorts first and then lays the sorted list out in rows of four. Because the result is a spilled array, you can feed it to HSTACK, VSTACK or INDEX as well.
Notes
A wrap count of 0 or less returns #NUM!. The result spills down and to the right, and #SPILL! means those cells aren't empty. Read the whole grid in another formula with #, as in =ROWS(C2#). See FILTER for details.
WRAPROWS needs Microsoft 365, Excel 2024 or later, or Excel for the web.