The Excel HSTACK function places two or more ranges or arrays side by side — left to right — into a single spilled result. It’s the horizontal twin of VSTACK: use it to bolt columns from different places into one live table, build custom report layouts, or assemble lookup tables on the fly.
#N/A.
Syntax
| Argument | Description | |
|---|---|---|
array1 | Required | The first range or array. |
array2, … | Optional | More ranges or arrays, appended in order to the right of the previous one. Up to 254 in total. |
Available in: Excel for Microsoft 365, Excel 2024+, and Excel for the web. Older versions show #NAME?. Column counts can differ freely; it’s the row counts that should match.
Combine column blocks side by side
Product names and Q1 sales sit in A1:B4; Q2 sales live separately in D1:D4. One formula joins them into a three-column table:
| A | B | D | ||
|---|---|---|---|---|
| 1 | Product | Q1 | Q2 | |
| 2 | Laptops | $12,400 | $13,100 | |
| 3 | Monitors | $8,100 | $8,800 | |
| 4 | Keyboards | $2,950 | $3,400 |
The combined table spills right and down from the formula cell:
| F | G | H | |
|---|---|---|---|
| 1 | Product | Q1 | Q2 |
| 2 | Laptops | $12,400 | $13,100 |
| 3 | Monitors | $8,100 | $8,800 |
| 4 | Keyboards | $2,950 | $3,400 |
Add a calculated column in the same breath — arrays you build inline are fair game:
Try it: interactive HSTACK demo
Pick two column blocks to combine — one of them is a row short, so you can watch the #N/A padding appear.
The real power: build tables other functions can use
HSTACK shines when a function wants a table you don’t actually have. Need a two-column lookup table for XLOOKUP return values, or a VLOOKUP table whose columns live far apart? Assemble it inline:
Pair HSTACK with VSTACK to build a complete grid — headers, labels, and data — in one formula:
Or return several results from one FILTER-style expression: stack the columns you want, in the order you want:
Errors & common pitfalls
#N/A — ragged heights. If one array has fewer rows than another, HSTACK pads the missing cells with #N/A. Supply equal-height arrays, or wrap the stack in IFERROR to blank the padding: =IFERROR(HSTACK(a, b), "").
#SPILL! — no room to land. The combined array needs empty cells to the right and below the formula. Clear whatever is in the way.
#NAME? — older Excel. HSTACK requires Excel for Microsoft 365 or Excel 2024+. In older versions the name isn’t recognized.
Pitfall: rows must line up by position. HSTACK glues arrays together by row number, not by matching keys. If the two blocks are sorted differently, you’ll pair the wrong rows — silently. When rows need to be matched by a key, use XLOOKUP instead.
Pitfall: the result is values only. Formatting, column widths, and styles don’t travel with the stacked data.
Practice workbook
Frequently asked questions
Which Excel versions have HSTACK?
#NAME?.What happens when my arrays have different heights?
#N/A. Supply equal heights, or wrap in IFERROR to blank the padding.What's the difference between HSTACK and VSTACK?
Can HSTACK reorder or pick columns from a table?
=HSTACK(C2:C8, A2:A8). For picking columns by number from one range, CHOOSECOLS is the purpose-built tool.Master functions like this in one day
This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class