HSTACK Function

Joins arrays side by side into one wider array.

Category

Lookup & Reference

Available in

Microsoft 365, Excel 2024

Returns

A spilled array

Taught hands-on in Level 5: Expert Techniques & Workbook Architecture · Modern Functions module

Overview

HSTACK places ranges next to each other, left to right. It's perfect for rearranging columns or adding a calculated column alongside existing data.

If the arrays are different heights, the shorter ones are padded with #N/A.

Syntax

=HSTACK(array1, [array2], …)

Arguments

ArgumentRequired?What it does
array1YesThe first array or range.
array2, …OptionalMore arrays to append to the right.

Examples

Example 1 — Reordering columns

Put the Sales column before the Rep column.

D1fx=HSTACK(B1:B3, A1:A3)
ABCDE
1RepSalesSalesRep
2Ana400400Ana
3Ben350350Ben
=HSTACK(B1:B3, A1:A3) Explain

Example 2 — Adding a calculated column

Show the data with a 10% bonus column attached.

=HSTACK(A2:B10, B2:B10 * 0.1) Explain
Wrap in IFNA(…, "") to blank out any #N/A padding when the arrays differ in height.

Common mistakes

  • #N/A in the result. The arrays have different heights. Pad with IFNA or EXPAND.

Notes

Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.