Introduction

The HSTACK function appends two or more arrays side by side, from left to right, and returns one wider array. It is useful when you want to combine columns from multiple sources with a single formula.

Syntax

=HSTACK(array1, [array2], ...)

Depending on your regional settings, Excel may use commas or semicolons between arguments.

Arguments

  • array1 — The first array to combine. This argument is required.
  • array2 — An additional array placed to the right of the preceding array. This argument is optional; you can include multiple arrays.

Excel Versions

Microsoft lists HSTACK for Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel for the web, Excel 2024, and Excel 2024 for Mac. The function page does not list Excel 2021 or earlier versions.

Examples

The examples use two tables placed in a worksheet.

First table in A2:B3:

A (Product)B (Quantity)
Apples5
Pears3

Second table in D2:E3:

D (Color)E (Region)
RedEast
GreenWest
  1. Join both tables side by side. In an empty cell, enter =HSTACK(A2:B3,D2:E3). The result has four columns—Product, Quantity, Color, and Region—with each row's values kept together.
  2. Combine three columns from separate locations. If product names are in A2:A4, prices in C2:C4, and stock counts in E2:E4, use =HSTACK(A2:A4,C2:C4,E2:E4). The result shows name, price, and stock in that order.
  3. Combine arrays with different row counts. For a first table in A2:B4 and a second array in D2:E3, use =HSTACK(A2:B4,D2:E3). HSTACK returns a three-row result; the extra row for the shorter array displays #N/A.
  4. Replace padding errors with hyphens. For arrays with different row counts, use =IFERROR(HSTACK(A2:B4,D2:E3),"-"). The padded #N/A cells display as hyphens. Keep in mind that IFERROR also hides other errors from the wrapped formula.

Tips

  • HSTACK always appends arrays horizontally; argument order controls the order of the output columns.
  • Use arrays with the same number of rows if you do not want #N/A in extra rows.
  • Enter the formula where there is enough empty space. Existing content in the output area can cause #SPILL!.
  • If your workbook uses semicolons as argument separators, write a formula such as =HSTACK(A2:B3;D2:E3).

Common Errors

  • #N/A in the bottom rows: One array has fewer rows than the tallest array. Match the row counts or handle padding with IFERROR when appropriate.
  • #SPILL!: The output area is blocked or cannot accommodate the result. Clear the obstructing cells.
  • #NAME? or unrecognized function: Your Excel version may not support HSTACK. Check the app version and updates.
  • Output columns appear in the wrong order: HSTACK follows the order of arrays in the formula. Reorder the arguments.

Compatibility

HSTACK returns a dynamic array and requires an Excel version that supports the function. Microsoft lists Microsoft 365 (Windows and Mac), Excel for the web, and Excel 2024 (Windows and Mac). For versions without HSTACK, arrange the columns manually or use a formula compatible with your data layout. Also check your regional argument separator.

Source: HSTACK function — Microsoft Support (accessed December 3, 2026).

Conclusion

HSTACK combines multiple arrays side by side without manually copying each column. Try the examples and make sure the row counts and output space fit your data.