# HSTACK in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/hstack/

HSTACK appends ranges horizontally, left to right, and returns one larger array. Rows are matched by position, so it is the quick way to rebuild a table from columns that are not next to each other.

## Syntax

```
HSTACK(range1; [range2, …])
```

## Arguments

- `range1` (range, required: yes): The first range or array.
- `range2, ...` (range, required: no): More ranges or arrays, appended to the right in order.

## Examples

The examples use this table, starting in A1:

| Name | City | Qty | Price |
|---|---|---|---|
| Ana | Cluj | 3 | 10 |
| Dan | Iasi | 5 | 8 |
| Mia | Sibiu | 2 | 15 |

```
=HSTACK(A2:A4,C2:C4)
```

Result: 

| Ana | 3 |
|---|---|
| Dan | 5 |
| Mia | 2 |

Puts two separate columns side by side, skipping the City column. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=HSTACK(A1:A4,D1:D4)
```

Result: 

| Name | Price |
|---|---|
| Ana | 10 |
| Dan | 8 |
| Mia | 15 |

Headers travel with the data when the ranges include row 1. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=HSTACK(A2:A4,ARRAYFORMULA(C2:C4*D2:D4))
```

Result: 

| Ana | 30 |
|---|---|
| Dan | 40 |
| Mia | 30 |

Adds a computed column next to the names: quantity times price. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=HSTACK({1;2;3},{"a";"b";"c"})
```

Result: 

| 1 | a |
|---|---|
| 2 | b |
| 3 | c |

Typed arrays work too. Here two columns of three rows each. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SORT(HSTACK(A2:A4,C2:C4),2,FALSE)
```

Result: 

| Dan | 5 |
|---|---|
| Ana | 3 |
| Mia | 2 |

Stack first, then sort the result by the second column, largest first. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- Ranges with different heights are padded with #N/A in the missing cells. Make the ranges the same height, or wrap the result in IFERROR.
- The result is as wide as all inputs together and as tall as the tallest one: COLUMNS(HSTACK(A1:B4,C1:C4,D1:D4)) is 4.
- Rows are joined by position, not by key. If two tables are in a different order, align them first or use a lookup.
- Typed arrays use "," between columns in en_US. In ro_RO the same array needs "\".

## Compared with Excel

Same function and arguments as Excel 365 HSTACK.

## Related functions

- [VSTACK](https://goingstellar.ro/reference/sheets/vstack/)
- [CHOOSECOLS](https://goingstellar.ro/reference/sheets/choosecols/)
- [CHOOSEROWS](https://goingstellar.ro/reference/sheets/chooserows/)
- [ARRAYFORMULA](https://goingstellar.ro/reference/sheets/arrayformula/)
- [SORT](https://goingstellar.ro/reference/sheets/sort/)
- [TRANSPOSE](https://goingstellar.ro/reference/sheets/transpose/)

## Sources

- [HSTACK (Docs Editors Help)](https://support.google.com/docs/answer/13190756)

