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], ...)| Argument | What it means | |
|---|---|---|
array1 | Required | The first range or array. |
array2, ... | Optional | More 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
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Product | Jan | Feb | Product | Jan | Feb | ||
| 2 | Keyboard | 120 | 135 | Keyboard | 120 | 135 | ||
| 3 | Mouse | 340 | 310 | Mouse | 340 | 310 | ||
| 4 | Webcam | 85 | 92 | Webcam | 85 | 92 |
The Jan block and the Feb column are joined without the empty column C.
2Add a calculated column
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Product | Jan | Feb | ||||
| 2 | Keyboard | 120 | 135 | Keyboard | 15 | ||
| 3 | Mouse | 340 | 310 | Mouse | -30 | ||
| 4 | Webcam | 85 | 92 | Webcam | 7 |
Next to each product, the change from January to February is calculated for all rows at once.
3Different heights padded with blanks
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Product | Jan | Feb | ||||
| 2 | Keyboard | 120 | 135 | Keyboard | Best seller | ||
| 3 | Mouse | 340 | 310 | Mouse | |||
| 4 | Webcam | 85 | 92 | Webcam |
The single text value is only one row tall, so HSTACK pads it with #N/A; IFNA turns those into empty text.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | Inputs 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.
| Language | Function name |
|---|---|
| Czech | SROVNAT.VODOROVNĚ |
| Danish | HSTAK |
| Dutch | HOR.STAPELEN |
| Finnish | HPINO |
| French | ASSEMB.H |
| German | HSTAPELN |
| Hungarian | VÍZSZ.HALMOZÁS |
| Italian | STACK.ORIZ |
| Norwegian (Bokmål) | HSTAKK |
| Polish | STOS.POZ |
| Portuguese (Portugal) | JUNTARH |
| Russian | ГСТОЛБИК |
| Spanish | APILARH |
| Turkish | YATAYYIĞ |