HSTACK Function in Excel: Put Arrays Side by Side

HSTACK Function in Excel: Put Arrays Side by Side featured illustration

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 min readUpdated 13 October 2026

Dynamic ArrayLevel: ExpertAvailable in: Excel 365 / 2021+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. HSTACK in practice
  5. Where you will use it
  6. Worked example
  7. Mistakes people make
  8. Related functions
  9. Continue learning

HSTACK joins arrays horizontally β€” build a small report from separate results in one formula.

Advertisement

Syntax

=HSTACK(array1, [array2], ...)
Argument What it means
array1… Arrays to place next to each other.

Examples

Example 1

=HSTACK(UNIQUE(B2:B500), SUMIFS(E2:E500, B2:B500, UNIQUE(B2:B500)))

Each region with its total.

HSTACK in practice

Where you will use it

  • Join two tables side by side
  • Add a calculated column to a spilled result
  • Build report layouts

Worked example

CaseFormulaResult
1=ARRAYTOTEXT(CHOOSE(A2,HSTACK({"A";"B"},{1;2}),HSTACK({"x"},{"y"},{"z"}),HSTACK({"A";"B";"C"},{1;2})))A, 1, B, 2
2=ARRAYTOTEXT(CHOOSE(A3,HSTACK({"A";"B"},{1;2}),HSTACK({"x"},{"y"},{"z"}),HSTACK({"A";"B";"C"},{1;2})))x, y, z
3=ARRAYTOTEXT(CHOOSE(A4,HSTACK({"A";"B"},{1;2}),HSTACK({"x"},{"y"},{"z"}),HSTACK({"A";"B";"C"},{1;2})))A, 1, B, 2, C, #N/A

Results calculated in Excel. Row 3 shows the #N/A padding you get when the arrays have different heights.

Mistakes people make

MistakeWhat to do instead
Different heightsShorter arrays are padded with #N/A; wrap in IFNA
Older ExcelNeeds Microsoft 365

VSTACK Β· UNIQUE

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

  • πŸ“—
    Practice workbook: Dynamic arrays18 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 35 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong

Leave a Reply

Your email address will not be published. Required fields are marked *