VSTACK works equally well for ranges on a worksheet or in-memory arrays created by a formula. The output from VSTACK is fully dynamic. If data in the given arrays changes, the result from VSTACK will immediately update. VSTACK works well with Excel Tables, as seen in the worksheet above, since Excel Tables automatically expand when new data is added. Use VSTACK to combine ranges vertically and HSTACK to combine ranges horizontally.

Basic usage

VSTACK stacks ranges or arrays vertically. In the example below, the range B3:B5 is combined with the range B8:B9. Each subsequent range/array is appended to the bottom of the previous range/array. The formula in D3 is:

Range with array

VSTACK can work interchangeably with both arrays and ranges. In the worksheet below, we combine the array constant {“Color”,“Qty”} with the range B3:C7. The formula in E3 is:

Arrays of different size

When VSTACK is used with arrays of different size, the smaller array will be expanded to match the size of the larger array. In other words, the smaller array is “padded” to match the size of the larger array, as seen in the example below. The formula in cell E5 is:

By default, the cells used for padding will display the #N/A error. One option for trapping these errors is to use the IFERROR function. The formula in H5 is: In this formula IFERROR is configured to replace errors with an empty string (""), which displays as an empty cell.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.