Function Problems

Combine and Sort Excel Arrays with VSTACK, CHOOSECOLS, FILTER, and SORT

Algirdas JasaitisAlgirdas Jasaitis Nov 12, 2026 871 views

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.

Combine and Sort Multiple Excel Arrays with Dynamic Array Functions
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.
Before you start

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.

Solution 1Recommended

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.

1
Choose an empty output cell

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.

2
Enter the dynamic array formula

Enter =SORT(FILTER(CHOOSECOLS(VSTACK(A2:C10,E2:G10),1,3),CHOOSECOLS(VSTACK(A2:C10,E2:G10),1)<>""),1,1) and press Enter.

3
Adjust the source ranges and selected columns

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.

4
Set the sorting order

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.

Stack, filter, select, and sort the arrays in one formula
The result updates dynamically: When supported by your spreadsheet version, changes to values within the referenced ranges are reflected automatically in the spilled result.
Dynamic spreadsheet formulas

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. 1. Open the workbook in WPS Spreadsheet: Launch WPS Office, choose Spreadsheets, and open the Excel workbook containing the source ranges.
  2. 2. Select the output starting cell: Click an empty cell such as J2, leaving enough blank cells for the dynamic result to expand.
  3. 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. 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.
Create a combined, automatically updating array from multiple spreadsheet ranges.Use dynamic sorting and filtering to avoid helper columns and repeated manual sorting.Open, edit, and save Microsoft Excel .xlsx files with format compatibility.Work in a familiar spreadsheet interface designed for efficient Excel-style formula migration.
microsoft office alternative - wps office

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.