Lookup & reference function

HSTACK function

Joins ranges or arrays side by side, left to right, into one array.

Available in Microsoft 365, Excel 2024, Excel for the web, Excel for Mac 2024+

Excel 2024 and laterWorks in Google Sheets

Syntax

HSTACK(array1, [array2], ...)
ArgumentWhat it means
array1RequiredThe first range or array.
array2, ...OptionalMore ranges or arrays to place to the right, in order.

Returns: One array as tall as the tallest input and as wide as all inputs combined; it spills.

How HSTACK works

HSTACK places arrays next to each other horizontally. It is the quickest way to build a report from columns that are not adjacent in the source, to add a calculated column to a range, or to put the output of two formulas side by side so that functions like SORT can treat them as one table.

Each input is placed to the right of the previous one. When the inputs have different heights, the shorter ones are padded with #N/A; wrap the formula in IFNA to show blanks instead. Its vertical partner is VSTACK.

Examples

1Combine columns that are not adjacent

F1fx=HSTACK(A1:B4, D1:D4)
ABCDEFGH
1ProductJanFebProductJanFeb
2Keyboard120135Keyboard120135
3Mouse340310Mouse340310
4Webcam8592Webcam8592

The Jan block and the Feb column are joined without the empty column C.

2Add a calculated column

F2fx=HSTACK(A2:A4, D2:D4 - B2:B4)
ABCDEFG
1ProductJanFeb
2Keyboard120135Keyboard15
3Mouse340310Mouse-30
4Webcam8592Webcam7

Next to each product, the change from January to February is calculated for all rows at once.

3Different heights padded with blanks

F2fx=IFNA(HSTACK(A2:A4, "Best seller"), "")
ABCDEFG
1ProductJanFeb
2Keyboard120135KeyboardBest seller
3Mouse340310Mouse
4Webcam8592Webcam

The single text value is only one row tall, so HSTACK pads it with #N/A; IFNA turns those into empty text.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 16 KB

Common errors and how to fix them

ErrorWhy it happensFix
#N/AInputs of different heights were padded.Wrap in IFNA or make all inputs the same height.
#SPILL!The output area is blocked.Clear the cells to the right and below the formula.

Tips

  • =SORT(HSTACK(A2:A4, D2:D4), 2, -1) sorts products by February units without touching the source.
  • HSTACK keeps the original order of columns; use CHOOSECOLS when you need to reorder within one range.

Google Sheets

HSTACK also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

HSTACK in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
CzechSROVNAT.VODOROVNĚ
DanishHSTAK
DutchHOR.STAPELEN
FinnishHPINO
FrenchASSEMB.H
GermanHSTAPELN
HungarianVÍZSZ.HALMOZÁS
ItalianSTACK.ORIZ
Norwegian (Bokmål)HSTAKK
PolishSTOS.POZ
Portuguese (Portugal)JUNTARH
RussianГСТОЛБИК
SpanishAPILARH
TurkishYATAYYIĞ

Recipes that use HSTACK