WRAPCOLS folds a single list into a grid, filling it column by column. Give it twelve months and a wrap count of 4 and you get four rows and three columns: January to April in the first column, May to August in the second and September to December in the third.
The arguments
- vector is the list to wrap. It must be one column or one row. A block with several rows and columns returns
#VALUE!. Flatten it with TOCOL first. - wrap_count is how many values go in each column. The number of columns is worked out for you: 12 values with a wrap count of 4 gives 3 columns.
- pad_with fills the gap when the last column isn't full.
Reading order
WRAPCOLS fills top to bottom, then moves right, like the columns of a newspaper. That makes it the right choice when each column is a group: quarters of months, shifts of staff, pages of items. WRAPROWS fills left to right, then moves down, like lines of text.
With the same twelve months, WRAPCOLS(A2:A13,4) gives:
- Jan, Feb, Mar and Apr in the first column
- May, Jun, Jul and Aug in the second
- Sep, Oct, Nov and Dec in the third
Each column holds one third of the year, so adding a heading above each column makes a clean quarter-by-quarter table.
Uneven lists
Seven items with a wrap count of 3 fill two columns and put a single item in the third. By default the missing cells show #N/A. Pad them instead: =WRAPCOLS(A2:A8,3,"-") fills the last column with dashes, and 0 fills with zeros. The padding appears only in the last column.
Reshaping data
Data that arrives as one long row can be turned into records. If each record has 4 fields and the data is in a row, =WRAPCOLS(A1:X1,4) returns one record per column, which you can flip with TRANSPOSE if you need records in rows. For the more usual case of a long column, WRAPROWS gives one record per row.
Combining it with other functions
WRAPCOLS accepts the output of other functions. =WRAPCOLS(SORT(A2:A13),4) sorts first and then wraps. =WRAPCOLS(TOROW(A2:C5),2) wraps a flattened block into columns of two.
Notes
A wrap count of 0 or less returns #NUM!. The result spills down and to the right, so #SPILL! means those cells aren't empty. The # operator reads the whole grid, as in =COLUMNS(C2#). See FILTER for more on spills.
WRAPCOLS needs Microsoft 365, Excel 2024 or later, or Excel for the web.