How many columns result
| A | B | C | |
|---|---|---|---|
| 1 | Region | Rep | Amount |
| 2 | East | Ana | 1200 |
| 3 | West | Ben | 850 |
| 4 | East | Cara | 430 |
| 5 | North | Dan | 970 |
| 6 | West | Eli | 1500 |
Formula: F2: =COLUMNS(HSTACK(A2:B3,C2:C3))
Result: 3
A two-column block plus a one-column block make three columns.
HSTACK with worked examples you can test in the live grid. The argument details are in the Excel guide.
The arguments and common errors are covered in the HSTACK Excel guide; check the function help in Google Sheets for its own argument list.
| A | B | C | |
|---|---|---|---|
| 1 | Region | Rep | Amount |
| 2 | East | Ana | 1200 |
| 3 | West | Ben | 850 |
| 4 | East | Cara | 430 |
| 5 | North | Dan | 970 |
| 6 | West | Eli | 1500 |
Formula: F2: =COLUMNS(HSTACK(A2:B3,C2:C3))
Result: 3
A two-column block plus a one-column block make three columns.
| A | B | C | |
|---|---|---|---|
| 1 | Region | Rep | Amount |
| 2 | East | Ana | 1200 |
| 3 | West | Ben | 850 |
| 4 | East | Cara | 430 |
| 5 | North | Dan | 970 |
| 6 | West | Eli | 1500 |
Formula: F2: =TEXTJOIN(", ",,HSTACK(B2:B3,C2:C3))
Result: Ana, 1200, Ben, 850
TEXTJOIN reads across each row of the 2-by-2 result: Ana and 1200, then Ben and 850.
| A | B | C | |
|---|---|---|---|
| 1 | Region | Rep | Amount |
| 2 | East | Ana | 1200 |
| 3 | West | Ben | 850 |
| 4 | East | Cara | 430 |
| 5 | North | Dan | 970 |
| 6 | West | Eli | 1500 |
Formula: F2: =INDEX(HSTACK(B2:B4,C2:C3),3,2)
Result: #N/A
The second array has only two rows, so row 3 of its column is padded with #N/A.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =HSTACK(A2:A4,C2:C4)
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Region | Product | Units | Price | Result | ||
| 2 | East | Pen | 120 | 2.5 | East | 120 | |
| 3 | West | Pen | 80 | 2.5 | West | 80 | |
| 4 | East | Book | 45 | 12 | East | 45 | |
| 5 | North | Book | 60 | 12 | |||
| 6 | West | Lamp | 30 | 25 | |||
| 7 | East | Lamp | 15 | 25 |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page