Data Import & Export

How to Split Excel Rows into Multiple Rows Using Dynamic Array Formulas

Huda QurayshiHuda Qurayshi Nov 11, 2026 870 views

Question details

The user needs to unpivot a row-based dataset into multiple output rows by repeating key fields and converting horizontal arrays into single columns.

How to Split Excel Rows into Multiple Rows Using Dynamic Array Formulas
Product
Spreadsheet
Device & OS
not provided
Scenario
Transforming wide, cross-tabular datasets into a normalized, flat vertical format for database import or advanced data analysis.
Observed behavior
The goal is to automatically unpivot the data range using modern dynamic array functions rather than relying on manual copy-pasting or VBA macros.
Before you start

Ensure you are using a spreadsheet version that fully supports dynamic array functions (such as Microsoft 365 or the latest WPS Office version), as functions like TOCOL and HSTACK are not available in older legacy versions.

Solution 1Recommended

Use the LET, HSTACK, and TOCOL Functions to Unpivot Data

You can dynamically unpivot row-based data into vertical columns by defining data ranges with the LET function and reshaping the arrays using TOCOL and HSTACK.

This formula-based approach eliminates the need for Power Query or VBA. By utilizing the LET function, you can assign variables to your data block, headers, and identifiers, making the overall formula process much more efficient and readable.

1
Define the target data table with LET

Select an empty cell with enough surrounding space for the new array to spill. Begin your formula by defining the entire source range, for example: =LET(tbl, A1:H4,

2
Extract the core data, row codes, and column attributes

Continue the formula by separating the dataset components. Extract the numerical data area by dropping headers: data, DROP(tbl, 1, 1). Next, extract the row identifiers: code, DROP(TAKE(tbl,, 1), 1). Finally, extract the column headers: attr, DROP(TAKE(tbl, 1),, 1).

3
Stack the transformed arrays side-by-side

Combine the elements by appending the HSTACK function. Use TOCOL and SEQUENCE to correctly repeat the identifiers alongside the unpivoted data values: HSTACK(TOCOL(IF(SEQUENCE(, COLUMNS(data)), code)), TOCOL(IF(SEQUENCE(ROWS(data)), attr)), TOCOL(data))

4
Execute the formula to spill the results

Add the final closing parenthesis for the LET function and press Enter. The complete dynamic array will automatically spill downwards, displaying your unpivoted dataset.

Use the LET, HSTACK, and TOCOL Functions to Unpivot Data
Adding Static Custom Columns: If your output requires extra columns containing static values like "n/a" or specific language codes (e.g., "EN_CA"), you can append the EXPAND function to your result or embed additional IF statements within the HSTACK array.

Manage Dynamic Array Formulas Seamlessly in WPS Spreadsheet

WPS Spreadsheet offers comprehensive support for modern data manipulation techniques. You can easily unpivot and restructure complex datasets using the exact same dynamic array functions without needing to switch software.

  1. 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open the workbook containing the row-based data you need to split.
  2. 2. Input the unpivot formula: Select an empty cell and enter your =LET(...) dynamic array formula to define and reshape your data.
  3. 3. Press Enter to execute: Hit Enter. WPS Spreadsheet will automatically calculate the logic and spill the unpivoted columns into the adjacent blank cells.
  4. 4. Adjust and format headers: If needed, manually add new column headers above the spilled array and adjust the column widths to finalize your report.
Full format compatibility with Microsoft Excel files (.xlsx, .xls) and modern array formulas.Native support for advanced dynamic array functions including LET, TOCOL, HSTACK, and EXPAND.Lightweight and highly optimized performance for processing large, dynamic datasets effortlessly.Completely free to download and use for all your standard data import and export tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my dynamic array formula display a #NAME? error?

The #NAME? error typically appears if your spreadsheet software version does not support the functions used in the formula, such as LET, TOCOL, or HSTACK. You need to ensure you are using Microsoft 365, Excel 2021, or the latest version of WPS Office.

What exactly does the TOCOL function do when unpivoting data?

The TOCOL function takes an entire two-dimensional array or cell range and forces it into a single vertical column. This is a critical step in unpivoting, as it converts a wide grid of values into a long, flat list.

Can I unpivot data without using complex formulas?

Yes. If you prefer a non-formula approach, you can use the Power Query feature found in modern spreadsheet applications. By selecting your data and choosing 'Unpivot Columns' within the Power Query editor, you can achieve the exact same flat-table result through a visual interface.