Function Problems

How to Reshape Excel Arrays into Groups of Rows and Columns

Amos GikundaAmos Gikunda Nov 10, 2026 868 views

Question details

The user needs to transform a large data matrix into smaller, predefined blocks of specific depth and width so the data can be imported into another software application.

How to Reshape Excel Arrays into Groups of Rows and Columns
Product
Excel
Device & OS
not provided
Scenario
Preparing a large dataset for external export by grouping it into smaller, specific-sized array blocks.
Observed behavior
The data is currently formatted as a single large matrix, which does not meet the structural import requirements of the target application.
Before you start

Ensure your spreadsheet software is updated to a modern version that fully supports dynamic array functions, as legacy versions do not support WRAPROWS, WRAPCOLS, or LAMBDA.

Solution 1Recommended

Use a Custom LAMBDA Function to Reshape the Matrix

Create a reusable custom function using LAMBDA and dynamic arrays to programmatically divide the matrix into specified blocks.

This method uses a combination of advanced dynamic array functions (EXPAND, TOCOL, WRAPROWS, and WRAPCOLS) wrapped inside a reusable LAMBDA function. By defining this once, you can easily reshape any matrix by simply specifying the desired depth and width.

1
Open the Name Manager

Navigate to the Formulas tab on your ribbon and click on Name Manager. Click 'New' to define a new custom function.

2
Define the LAMBDA Formula

Name the function 'ReShapeMatrixλ'. In the 'Refers to' box, input your LAMBDA formula combining LET, EXPAND, TOCOL, and WRAPROWS to calculate and stack the arrays based on the provided depth and width variables.

3
Apply the Function

In an empty cell, type =ReShapeMatrixλ(A1:G50, 3, 3) (replacing the range with your actual data, and the 3s with your target block depth and width) to instantly generate the reshaped groups.

Use a Custom LAMBDA Function to Reshape the Matrix
Advanced Formula Usage: The custom LAMBDA can be further enhanced to accept optional arguments, such as stacking horizontally instead of vertically, or padding empty cells with specific text strings.

Manipulate Complex Arrays Easily in WPS Spreadsheet

WPS Spreadsheet provides robust support for modern dynamic array functions, making it incredibly easy to reshape, transpose, and group large datasets efficiently.

  1. 1. Open your matrix file: Launch WPS Spreadsheet and open the workbook containing the large dataset you need to reshape.
  2. 2. Enter dynamic array formulas: Select an empty destination cell and type standard dynamic array functions like =WRAPROWS(TOCOL(A1:D10), 3).
  3. 3. Export the formatted data: Once the array spills into the new shape, select the new blocks, copy them as values if necessary, and export the file via Menu > Save As into your required format.
Full compatibility with Microsoft Excel dynamic array functions like WRAPROWS, TOCOL, and VSTACKLightweight application that processes heavy matrix manipulations without freezingBuilt-in data export tools to seamlessly save reshaped tables for external software import
microsoft office alternative - wps office

Frequently Asked Questions

What are WRAPROWS and WRAPCOLS used for?

WRAPROWS and WRAPCOLS are dynamic array functions that take a 1D array (like a single column or row) and 'wrap' it into a 2D matrix by specifying a set number of values per row or column.

Why does my LAMBDA function return a #NAME? error?

This error typically occurs if your current spreadsheet software version does not support LAMBDA functions, or if the custom name was spelled incorrectly when calling it from the cell.

How do I handle merged cells when reshaping array data?

Merged cells create empty or null values in array processing. You can use the SCAN function in combination with your array formulas to dynamically fill down header values and bypass merged cell limitations.

Can I reshape matrix data without using complex formulas?

Yes. You can use Power Query (or the Data tab tools) to unpivot columns, apply groupings, and reshape your matrix using a graphical interface before loading the transformed data back into your sheet.