Summary
The Excel WRAPROWS function is used to convert a one-dimensional array into a two-dimensional array by wrapping values into separate rows. This function is handy for reformatting linear data into a more structured row-based format, ideal for specific analyses or presentation needs.
Syntax
=WRAPROWS(vector, wrap_count, [pad_with])
- vector: The one-dimensional array or range to wrap
- wrap_count: The maximum number of values in each row. When this count is reached, WRAPROWS starts a new row
- [pad_with]: [Optional] Value to use for filling any unfilled places in the final row
Return value
A two-dimensional array with values wrapped by row.
How to use
Use WRAPROWS by specifying the vector (one-dimensional array or range) and the wrap_count, which determines the number of values per row. Optionally, specify pad_with to fill any unfilled spots in the final row.
Examples
Simple WRAPROWS
Wrapping an Array into Rows: To convert a horizontal range into rows with a specific number of columns:
=WRAPROWS(A1:J1, 4)
This formula wraps the one-dimensional range A1:J1 into rows, each containing up to 4 values.
WRAPROWS with Different Wrap Counts
Varying Column Lengths in Wrapped Data: Adjusting the number of columns in each row:
=WRAPROWS(A1:J1, 3)
This formula converts the range A1:J1 into rows with up to 3 values each.
WRAPROWS with Padding
Using Padding to Fill Empty Spaces: To fill empty spaces with a specific value:
=WRAPROWS(A1:J1, 4, "Empty")
This wraps the range A1:J1 into rows of up to 4 columns each, using “Empty” to fill any unfilled spots in the last row.
WRAPROWS for Vertical Data
Wrapping a Vertical Range into Rows: Converting a vertical range into a structured row format:
=WRAPROWS(A1:A10, 2)
This formula takes the vertical range A1:A10 and wraps it into rows, each with up to 2 columns.
Advanced WRAPROWS
Complex Reorganization of Data with WRAPROWS: To reorganize data into rows with custom padding:
=WRAPROWS(A1:A12, 5, "N/A")
Converts the vertical range A1:A12 into rows with up to 5 columns each, using “N/A” to fill any gaps in the final row.
Additional Notes
- WRAPROWS is a valuable tool for transforming linear data sets into a structured row format.
- The function automatically starts a new row after reaching the specified wrap_count.
- WRAPROWS will return a #VALUE! error if the provided vector is not a one-dimensional array or range.