# HSTACK function in Excel

> HSTACK places ranges side by side to build one table, so you can pick columns that aren't next to each other, put them in a new order, or add a calculated column, all in one formula that updates with the source.

Source: https://spreadsheetpractice.com/functions/hstack · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

## Quick answer

- **What it does:** HSTACK places ranges side by side to build one table, so you can pick columns that aren't next to each other, put them in a new order, or add a calculated column, all in one formula that updates with the source.
- **Syntax:** `=HSTACK(array1, [array2], ...)`
- **Most common use:** `=HSTACK(A2:A5,D2:D5)` returns Ava Ruiz (Two columns that aren't next to each other)
- **Available in:** Excel 2024 and Microsoft 365
- **Category:** [Dynamic array functions](https://spreadsheetpractice.com/functions/category/dynamic-arrays)
- **Returns:** One array with the inputs side by side. Shorter inputs are padded with #N/A. It spills.

## What it does

HSTACK places ranges side by side to build one table, so you can pick columns that aren't next to each other, put them in a new order, or add a calculated column, all in one formula that updates with the source.

## Syntax

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

| Argument | Required? | What it is |
|---|---|---|
| `array1` | Required | The first range or array. |
| `array2` | Optional | The next range to place to the right. Add as many as you need, separated by commas. |

## Examples

Each result was calculated by running the formula on the sample sheet.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| F2 | `=HSTACK(A2:A5,D2:D5)` | Ava Ruiz (spills 4 × 2) | Two columns that aren't next to each other |
| I2 | `=HSTACK(C2:C5,A2:A5)` | ava@example.com (spills 4 × 2) | Columns in a new order: email, then name |
| L2 | `=SORT(HSTACK(A2:A5,D2:D5),2,-1)` | Chloe Park (spills 4 × 2) | The two-column table sorted by salary |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C | D | E | F | G | H | I | J | K | L | M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Name | Dept | Email | Salary |  | Name and salary |  |  | Email first |  |  | Highest paid first |  |
| 2 | Ava Ruiz | Sales | ava@example.com | $68,000 |  | Ava Ruiz | $68,000 |  | ava@example.com | Ava Ruiz |  | Chloe Park | $82,000 |
| 3 | Ben Cole | Support | ben@example.com | $54,000 |  | Ben Cole | $54,000 |  | ben@example.com | Ben Cole |  | Ava Ruiz | $68,000 |
| 4 | Chloe Park | Finance | chloe@example.com | $82,000 |  | Chloe Park | $82,000 |  | chloe@example.com | Chloe Park |  | Dev Shah | $61,000 |
| 5 | Dev Shah | Sales | dev@example.com | $61,000 |  | Dev Shah | $61,000 |  | dev@example.com | Dev Shah |  | Ben Cole | $54,000 |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| #N/A at the bottom of a column | One range is shorter than the others. Make every range cover the same rows. |
| #SPILL! | Something is in the cells the result needs. Clear everything below and to the right of the formula, or move it to an empty area. |
| #NAME? | HSTACK needs Excel 2024 or Microsoft 365. |

## Tips

- Add a calculated column on the fly: =HSTACK(A2:A9,B2:B9*C2:C9).
- Feed it to FILTER to return non-adjacent columns: =FILTER(HSTACK(A2:A5,D2:D5),B2:B5="Sales").

## Related functions

- [VSTACK](https://spreadsheetpractice.com/functions/vstack): VSTACK stacks ranges on top of each other into one list, such as this month's orders under last month's or one region's reps under another's.
- [FILTER](https://spreadsheetpractice.com/functions/filter): FILTER returns only the rows of a range that pass a test, such as every order from the West region.
- [TRANSPOSE](https://spreadsheetpractice.com/functions/transpose): TRANSPOSE flips a range so rows become columns and columns become rows.

## Questions

### How do I return non-adjacent columns with FILTER?

Build the source with HSTACK first: =FILTER(HSTACK(A2:A9,D2:D9),B2:B9="Sales") returns names and salaries for the Sales team.

### What is the difference between HSTACK and the & operator?

& joins text into one cell. HSTACK keeps each value in its own cell and returns a table with several columns.

## Practice

A graded HSTACK exercise ("Name and revenue") is on [the HSTACK page](https://spreadsheetpractice.com/functions/hstack). It is checked instantly, then re-checked on changed data.

Lessons that use HSTACK:

- [Lesson 30: VSTACK & HSTACK](https://spreadsheetpractice.com/learn/vstack-hstack) (Pro)

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
