ID EN
#Dynamic array

WRAPCOLS

Excel Functions

Wrap array into columns

Syntax

EXCEL
=WRAPCOLS(vector, wrap_count, [pad_with])

Arguments

Parameter Description
vector The array or range to wrap.
wrap_count Max values in each column.
pad_with [optional] Value to use for unfilled places.

Return Value

Array wrapped by column

Details

The WRAPCOLS function converts a one-dimensional array into a two-dimensional array by wrapping values into separate columns. The length of each column is given as the wrap_count argument: when the count is reached, WRAPCOLS starts a new column. The WRAPCOLS function takes three arguments: vector, wrap_count, and pad_with. Vector and wrap_count are both required. Vector must be a one-dimensional array or range. Wrap_count is a number that represents the length of each column. The final argument, pad_with, is an optional value to use if there are empty spots in the last column. If no value is supplied for pad_with, WRAPCOLS will return an #N/A error after all values in vector have been used. You can override this behavior by providing a custom value for the pad_with argument. WRAPCOLS outpu

Examples

Basic usage

WRAPCOLS outputs values "by column", working top to bottom, left to right. When wrap_count has been reached, WRAPCOLS starts a new column. In the work

EXCEL
=WRAPCOLS(C2:J2,4)
Wrap count

Wrap_count represents the maximum number of values in each column. Once the count has been reached, WRAPCOLS starts a new column. In the screen below,

EXCEL
=WRAPCOLS(B3:B14,4)
Wrap count

The formula in D10 uses a wrap_count of 4:

EXCEL
=WRAPCOLS(B3:B14,3)
Padding

If no value is supplied for pad_with, WRAPCOLS will return an #N/A error after all values in the source array have been accounted for. You will see th

EXCEL
=WRAPCOLS(B3:B12,4)
Padding

The input range contains only 10 cells, which is not evenly divisible by a wrap_count of 4. As a result, the last 2 cells return #N/A. The formula in

EXCEL
=WRAPCOLS(B3:B12,4,"x")

See Also

WRAPROWS TOROW TOCOL