Excel 2024: Stack Multiple Arrays


August 29, 2024 - by

Excel 2024: Stack Multiple Arrays

If you need to combine multiple arrays into a single array, you can stack multiple arrays vertically using VSTACK. Stack multiple arrays horizontally using HSTACK.

In the figure below, one array formula is returning the headings in A2:D2. A second array formula is returning the numbers in A3:D3. These are two separate arrays. If you needed to stack them into a single array, you could use =VSTACK(A2#,A3#).


Caution: If the arrays being stacked have different number of columns, Excel will fill the shorter arrays with #N/A. To prevent this, use the EXPAND function. =EXPAND(array, rows, columns, pad with). In the figure below, there are only 3 numbers in A3# and this causes the #N/A in D6. By using =VSTACK(A2#,EXPAND(A3#,1,4,"")) you can prevent the #N/A.

Tip

These examples are only stacking two arrays. You can stack up to 254 arrays.




This article is an excerpt from MrExcel 2024 Igniting Excel

Title photo by Iva Rajović on Unsplash