Combine and Sort Excel Arrays with VSTACK, CHOOSECOLS, FILTER, and SORT
Question details
The user needs a modern spreadsheet formula that combines multiple ranges into one dynamic result, selects needed columns, removes blank rows, and sorts the output.

- Product
- Microsoft Excel for Microsoft 365
- Device & OS
- not provided
- Scenario
- The user wants to reshape data from separate arrays or columns without using helper columns or manual sorting.
- Observed behavior
- The goal is a single automatically expanding sorted array based on the source ranges.
Confirm that the source ranges have the same number and order of columns before stacking them vertically. Use a version of Excel or WPS Spreadsheet that supports dynamic arrays and the VSTACK, CHOOSECOLS, FILTER, and SORT functions.
Stack, filter, select, and sort the arrays in one formula
Use this method when the ranges have matching columns and you want one dynamic result that updates as source values change.
VSTACK places one range below another. CHOOSECOLS keeps only the required columns, FILTER excludes rows with blank key values, and SORT orders the completed array.
Click a blank cell where the combined result should begin, such as J2. Ensure that the cells below and to the right are empty so the dynamic array can spill.
Enter =SORT(FILTER(CHOOSECOLS(VSTACK(A2:C10,E2:G10),1,3),CHOOSECOLS(VSTACK(A2:C10,E2:G10),1)<>""),1,1) and press Enter.
Replace A2:C10 and E2:G10 with your own ranges. In CHOOSECOLS, use 1,3 to return the first and third columns from the stacked array, or change the column numbers to match the fields you need.
In SORT(array,1,1), the second argument 1 sorts by the first returned column and the third argument 1 sorts ascending. Change the last 1 to -1 for descending order, or use another returned-column position to sort by a different column.

Use SORTBY when sorting by a column not shown in the output
Use SORTBY when you need to return selected columns but order them according to a separate source column, such as a date, ID, or priority field.
Use Power Query for repeatable data transformations
Use Power Query when you regularly combine larger tables, need additional cleanup steps, or want a refreshable query instead of a worksheet formula.
Combine and Sort Data Arrays in WPS Spreadsheet
WPS Spreadsheet lets you build dynamic results with modern array formulas. Stack matching ranges, return only the columns you need, filter empty records, and sort the spilled output from one formula when the functions are available in your installed version.
- 1. Open the workbook in WPS Spreadsheet: Launch WPS Office, choose Spreadsheets, and open the Excel workbook containing the source ranges.
- 2. Select the output starting cell: Click an empty cell such as J2, leaving enough blank cells for the dynamic result to expand.
- 3. Enter the array formula: Type =SORT(FILTER(CHOOSECOLS(VSTACK(A2:C10,E2:G10),1,3),CHOOSECOLS(VSTACK(A2:C10,E2:G10),1)<>""),1,1) and press Enter.
- 4. Customize the formula for your layout: Update the ranges, CHOOSECOLS column numbers, and SORT arguments to return and order the fields required for your report.

Frequently Asked Questions
What is the difference between VSTACK and HSTACK in Excel?
VSTACK combines ranges vertically by placing one range under another. HSTACK combines ranges horizontally by placing one range beside another. Use ranges with matching column counts for VSTACK and matching row counts for HSTACK.
Why does my dynamic array formula show a #SPILL! error?
A #SPILL! error means the formula cannot place its results into the required cells. Clear values, merged cells, or other content from the intended spill range, then enter the formula again.
How can I sort the result by a column that is not displayed?
Use SORTBY instead of SORT. For example, =SORTBY(CHOOSECOLS(VSTACK(A2:C10,E2:G10),1,3),CHOOSECOLS(VSTACK(A2:C10,E2:G10),2),1) displays columns 1 and 3 but sorts by column 2.
Can I remove blank rows after combining ranges?
Yes. Use FILTER with a nonblank condition on a key column, such as FILTER(VSTACK(A2:C10,E2:G10),CHOOSECOLS(VSTACK(A2:C10,E2:G10),1)<>"").
What should I use if VSTACK or CHOOSECOLS is unavailable?
Check for Microsoft 365 or a current spreadsheet version with dynamic array support. For repeatable transformations in older Excel versions, use Data > Get Data > From Table/Range and append the tables in Power Query.




