How to Use HSTACK Function in Excel + Tips
Learn how to use HSTACK function in Excel step-by-step to combine ranges horizontally side-by-side with simple examples and tips.
Hello everyone! Today i will show you how to use HSTACK function in Microsoft Excel step by step.
1. What is HSTACK Function in Excel?
The HSTACK function (Horizontal Stack) is a dynamic array function introduced in Excel 365 and Excel 2024. It allows you to combine two or more cell ranges or arrays side-by-side horizontally (left-to-right) into a single combined table.
Unlike manually copying and pasting columns next to each other, HSTACK is fully dynamic: whenever your original data updates, the combined table updates automatically!
2. 🛠️ Formula Syntax & Parameters
=HSTACK(array1, [array2], ...)
array1: Required. The first array or range of cells to combine.[array2], ...: Optional. Additional arrays or cell ranges to attach side-by-side to the right ofarray1.
3. 📋 Practical Examples
Example 1: Combine Two Non-Adjacent Columns Side-by-Side
Suppose cell range A2:A5 contains Employee Names and cell range C2:C5 contains Sales Amounts (skipping Column B):
| Cell | Column A (Name) | Column B (Dept) | Column C (Sales) |
|---|---|---|---|
| 2 | Sok | IT | $500 |
| 3 | Dara | HR | $700 |
| 4 | Lina | IT | $800 |
| 5 | Sam | Sales | $600 |
=HSTACK(A2:A5, C2:C5)
👉 Result: Returns a new 2-column table joining Name and Sales side-by-side, skipping Column B completely!
Example 2: Reorder Table Columns for Reports
You can use HSTACK to rearrange columns into a new order without modifying your original worksheet layout.
To display Sales (Col C) first and Name (Col A) second:
=HSTACK(C2:C5, A2:A5)
👉 Result:
| Column 1 (Sales) | Column 2 (Name) |
|---|---|
| $500 | Sok |
| $700 | Dara |
| $800 | Lina |
| $600 | Sam |
Example 3: Stack Ranges with Different Heights (Handling Missing Cells)
If array1 has 4 rows (A2:A5) and array2 has only 3 rows (D2:D4), HSTACK fills the missing cell in the shorter column with a #N/A error:
=HSTACK(A2:A5, D2:D4)
Wrap with IFNA to clean up #N/A errors:
=IFNA(HSTACK(A2:A5, D2:D4), "")
👉 Result: Replaces any missing row entries with a clean blank space "" instead of showing #N/A!
💡 Quick Tips for Using HSTACK Function
- Clean Up Missing Values with
IFNA: When stacking ranges of different heights/row counts, wrapHSTACKinsideIFNA(HSTACK(...), "")to replace#N/Aerrors with blank cells. - Easily Create Custom Lookup Tables:
HSTACKis great for creating temporary 2-column arrays insideXLOOKUPorVLOOKUPwhen your lookup column is located to the right of your return column. - Combine with
CHOOSECOLSorSORT: You can nestHSTACKinsideSORTto sort your combined horizontal table automatically:=SORT(HSTACK(A2:A5, C2:C5), 2, -1). - Excel Version Requirement:
HSTACKrequires Microsoft 365, Excel 2024, or Excel for the Web.
📚 Related Resources & Tutorials
Related Tutorials
Opens in new tab ↗How to Use VSTACK Function in Excel + Tips
Learn how to use VSTACK function in Excel step-by-step to combine ranges vertically top-to-bottom with simple examples and tips.
How to Use SEQUENCE Function in Excel + Tips
Learn how to use SEQUENCE function in Excel step-by-step to generate automatic numbers, dates, and tables with easy examples and tips.
How to Use TAKE Function in Excel + Tips
Learn how to use TAKE function in Excel step-by-step to extract the first or last N rows and columns from a range with simple examples and tips.