How to Stack Repeated Excel Column Groups Vertically
Question details
The user needs to vertically stack multiple repeated column groups (such as Job, Hours, and Location) from a large dataset, ensuring the corresponding record ID is repeated on every output row.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Reorganizing a wide dataset containing numerous repeated attribute sets across thousands of rows into a clean, unpivoted tabular format suitable for analysis.
- Observed behavior
- The data is currently spread horizontally across up to 90+ column groups, requiring manual or automated reshaping to stack the columns sequentially while maintaining index alignments.
Before applying these complex formulas, ensure your spreadsheet software supports modern Dynamic Array functions (such as VSTACK and LAMBDA) and consider converting your dataset into an official Table for easier referencing.
Use Dynamic Array Formulas to Stack Columns
Best for users who want a direct, formula-based approach to reshape and stack repeated columns without using external data editors.
You can combine modern dynamic array functions like VSTACK, REDUCE, LAMBDA, and CHOOSECOLS to systematically loop through your wide dataset and stack each group of columns underneath the previous one.
This approach recalculates automatically when your source data changes, eliminating the need to refresh data connections manually.
Select an empty cell in a new worksheet where you want the stacked data headers to begin.
Type the following dynamic array formula, adjusting the ranges to match your specific dataset columns: =VSTACK(A1:D1,DROP(REDUCE("",SEQUENCE(COUNTIF(A1:G1,"*job*"),,1,3),LAMBDA(a,i,VSTACK(a,HSTACK(A2:A3,CHOOSECOLS(B2:G3,i,i+1,i+2))))),1))
Press Enter. The formula will iterate through your defined column intervals and dynamically spill the vertically stacked rows into the cells below.
Unpivot Repeated Columns using Power Query
The ideal method for massive datasets containing thousands of rows where heavy array formulas might cause performance lag.
Use WPS Spreadsheet to Stack Data Flawlessly
WPS Office offers comprehensive support for modern dynamic array functions, allowing you to seamlessly process wide datasets and unpivot repeated columns without complicated setup.
- 1. Open your dataset: Launch WPS Spreadsheet and open the file containing your wide, repeated column groups.
- 2. Select the destination: Navigate to a blank worksheet or empty area and select a cell for your output.
- 3. Apply the array formula: Input the array formula utilizing VSTACK and CHOOSECOLS to reference your data.
- 4. Generate the stacked results: Press Enter to instantly populate and spill the reshaped columns vertically.

Frequently Asked Questions
Can I stack columns without using Power Query?
Yes. If you are using a modern spreadsheet version, you can combine dynamic array functions like VSTACK, REDUCE, and CHOOSECOLS to programmatically stack columns. This mimics the unpivot behavior of Power Query using entirely formula-based logic.
Why is my dynamic array formula returning a #SPILL! error?
A #SPILL! error occurs when the destination range required to display all the stacked data is obstructed. Clear any text, formatting, or hidden characters in the cells below and adjacent to your formula to resolve this.
Is there a limit to how many rows I can stack?
Spreadsheet software typically supports up to 1,048,576 rows per sheet. However, heavily nested array formulas processing tens of thousands of rows might cause calculation slowdowns. For highly dense datasets, using Power Query or specialized database tools is recommended.
What is the purpose of CHOOSECOLS in the formula?
The CHOOSECOLS function extracts specific columns from an array by their index numbers. In a stacking formula, it allows you to precisely target the next repeated group (e.g., Job, Hours, Location) for each iteration so they align properly in the output.




