Applies ToExcel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web

Wraps the provided row or column of values by columns after a specified number of elements to form a new array.

Syntax

=WRAPCOLS(vector, wrap_count, [pad_with])

The WRAPCOLS function syntax has the following arguments:

  • vector       The vector or reference to wrap.

  • wrap_count       The maximum number of values for each column.

  • pad_with       The value with which to pad. The default is #N/A.

Remarks

The elements of the vector are placed into a 2-dimensional array by column. Each column has wrap_count elements. The column is padded with pad_with if there are insufficient elements to fill it. If wrap_count is greater or equal to the number of elements in vector, then the vector is simply returned in a single column.

Errors

  • Excel returns a #VALUE when vector is not a one-dimensional array.

  • Excel returns a #NUM when wrap_count is less than 1.

  • Excel returns a #N/A error for each cell in the return array that has no results.

Examples

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data.

Wraps the row in range A2:G2 to an array in range A4:C6 of 3 rows. The last two missing elements return #N/A.  

Data

A

B

C

D

E

F

G

Formulas

=WRAPCOLS(A2:F2,3)

Wraps the row in range A2:G2 to an array in range A4:C6 of 3 columns. The last two missing elements return the pad character "x".

Data

A

B

C

D

E

F

G

Formulas

=WRAPCOLS(A2:G2,3,"x")

See Also

CHOOSECOLS function

CHOOSEROWS function

WRAPROWS function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.