HSTACK function
HSTACK joins arrays side by side into one larger array, which helps when you want to combine ranges from different places into one table. Shorter arrays are padded with #N/A.
Example
Read it as a sentence: place B1:B3 and F1:F3 side by side into one block, which starts with Item.
Syntax
HSTACK(array1, [array2], ...)
Arguments in [square brackets] are optional.
-
array1(required) - First array.
-
array2(optional) - More arrays to append to the right.
Returns: The arrays joined side by side.
One HSTACK formula can fill more than one cell. When the result has several values, they spill into the cells below or to the right of the formula.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=HSTACK({1;2},{3;4}) | 1 | Two columns |
=HSTACK({1;2},{3;4;5}) | 1 | Uneven heights |
=HSTACK(1,"a",TRUE) | 1 | Scalars |
=IFERROR(HSTACK({1;2},{3;4;5}),"") | 1 | Hide padding |
=HSTACK(Items!B1:B3,Data!F1:F3) | Item | Blank cells inside |
The Items sheet these formulas read
The Data sheet these formulas read
A cell that starts with = holds that formula.
Watch out for
- Shorter arrays are padded with #N/A.
- Output height equals the tallest input.
Where it works
- Excel
- HSTACK arrived in Excel 2024. Older versions do not have it. 365, Excel for the web and Excel 2024; not in older perpetual versions.
- Google Sheets
- Same name, same behaviour for everyday use. Sheets has HSTACK too; a {range1, range2} array literal also works.
Part of Lookup and reference functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .