HSTACK Function

Excel Functions › Lookup & Reference

Excel 365 Excel 2024+ Dynamic Array

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.


Quick answer: to put a column block from one place next to a column block from another:
=HSTACK(A2:B4, D2:D4)
The result spills to the right and down. Arrays should have the same number of rows — HSTACK pads shorter arrays with #N/A.

Syntax

=HSTACK(array1, [array2], …)
ArgumentDescription
array1RequiredThe first range or array.
array2, …OptionalMore 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:

ABD
1ProductQ1Q2
2Laptops$12,400$13,100
3Monitors$8,100$8,800
4Keyboards$2,950$3,400
=HSTACK(A1:B4, D1:D4) // spills a 4-row x 3-column result

The combined table spills right and down from the formula cell:

FGH
1ProductQ1Q2
2Laptops$12,400$13,100
3Monitors$8,100$8,800
4Keyboards$2,950$3,400

Add a calculated column in the same breath — arrays you build inline are fair game:

=HSTACK(A2:B4, D2:D4, B2:B4+D2:D4) // Product, Q1, Q2, and a live Total column

Try it: interactive HSTACK demo

Live 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:

=VLOOKUP(G2, HSTACK(A2:A50, F2:F50), 2, FALSE) // lookup table built from columns A and F

Pair HSTACK with VSTACK to build a complete grid — headers, labels, and data — in one formula:

=VSTACK(HSTACK("Product", "Q1", "Q2"), HSTACK(A2:A4, B2:B4, D2:D4))

Or return several results from one FILTER-style expression: stack the columns you want, in the order you want:

=HSTACK(C2:C8, A2:A8) // reorder columns - Amount first, then Customer

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

📊
Download the free HSTACK practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

Which Excel versions have HSTACK?
Excel for Microsoft 365, Excel 2024 and later, and Excel for the web. Older versions (2021, 2019, 2016) show #NAME?.
What happens when my arrays have different heights?
Different column counts are fine. Different row counts cause HSTACK to pad the shorter array with #N/A. Supply equal heights, or wrap in IFERROR to blank the padding.
What's the difference between HSTACK and VSTACK?
Direction. HSTACK appends arrays beside each other (more columns); VSTACK appends them below each other (more rows).
Can HSTACK reorder or pick columns from a table?
Yes — stack the columns in any order you like: =HSTACK(C2:C8, A2:A8). For picking columns by number from one range, CHOOSECOLS is the purpose-built tool.
Does HSTACK match rows by a key, like a join?
No — it pairs rows purely by position. If the blocks are sorted differently you get scrambled pairings with no warning. Use XLOOKUP or INDEX/MATCH to match by key.

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

Related functions: VSTACK · TOROW · WRAPCOLS · FILTER · XLOOKUP