Excel functions / Dynamic arrays
HSTACK function
Places arrays side by side into one wider array.
Syntax
=HSTACK(array1, [array2], …)
Arguments
array: The arrays to join, left to right.
When to use it
HSTACK joins ranges side by side into one array, which spills. VSTACK stacks them one under another. Use it to build a report from columns that are not next to each other, or from the results of other formulas.
Examples
Two columns that are apart
A B C D E F 1 Region Rep Sales Sales Region 2 North Ana 1200 1200 North 3 South Ben 800 800 South 4 North Chloe 900 5 West Ana 400 6 North Ana 300 In E1:
=HSTACK(C1:C3, A1:A3)→ Sales, Region; 1200, North; 800, SouthA list with a calculated column
A B C D E F 1 Region Rep Sales Ana 1320 2 North Ana 1200 Ben 880 3 South Ben 800 4 North Chloe 900 5 West Ana 400 6 North Ana 300 In E1:
=HSTACK(B2:B3, C2:C3*1.1)→ Ana, 1320; Ben, 880
Common mistakes
- Different heights. A shorter range is filled out with #N/A. Wrap the result in IFNA to blank them.
HSTACK in other languages
Excel shows function names in its own language. In these languages it also puts a semicolon between arguments where English has a comma.
- Czech: SROVNAT.VODOROVNĚ
- Danish: HSTAK
- Dutch: HOR.STAPELEN
- Finnish: HPINO
- French: ASSEMB.H
- German: HSTAPELN
- Hungarian: VÍZSZ.HALMOZÁS
- Italian: STACK.ORIZ
- Norwegian: HSTAKK
- Polish: STOS.POZ
- Portuguese (Portugal): JUNTARH
- Russian: ГСТОЛБИК
- Spanish: APILARH
- Swedish: HSTACK
- Turkish: YATAYYIĞ
Practise it
Related functions
- VSTACK: Stacks arrays on top of each other into one taller array.
- CHOOSECOLS: Returns the columns you name from an array, in the order you name them.
- TOROW: Turns an array into a single row.
- EXPAND: Grows an array to a set number of rows and columns, filling the new cells.