Here, we will learn how to use the Excel dynamic array functions: HSTACK and VSTACK.
HSTACK function
The Excel HSTACK function combines the given arrays or ranges horizontally into a single array. Each subsequent array is appended to the right of the previous array. For example, to combine two horizontal arrays {1,2,3} and {4,5,6} horizontally, use HSTACK like this: =HSTACK({1,2,3},{4,5,6}). The function can be found in Excel 365 - Excel 2021. HSTACK takes the arguments like this: (array1, [array2],…), of which at least one array argument is required. Array accepts the first array or range to combine. Thereafter, the function accepts the subsequent optional array arguments. Note that the result of this function spills into multiple cells automatically onto the working worksheet. The formula in G4, is:
=HSTACK(A4:A11,C4:C11,E4:E11)
VSTACK function
The Excel VSTACK function combines the given arrays or ranges vertically into a single array. Each subsequent array is appended to the bottom of the previous array. For example, to combine two horizontal arrays {1,2,3} and {4,5,6} vertically, use VSTACK like this: =VSTACK({1,2,3},{4,5,6}). The function can be found in Excel 365 - Excel 2021. VSTACK takes the arguments like this: (array1, [array2],…), of which at least one array argument is required. Array accepts the first array or range to combine. Thereafter, the function accepts the subsequent optional array arguments. Note that the result of this function spills into multiple cells automatically onto the working worksheet. The formula in O4, is:
=VSTACK(K4:M6,K9:M11)
You have successfully learnt how to use the Excel dynamic array functions: HSTACK and VSTACK.