HSTACK joins arrays side by side. It builds one array out of several columns, ranges or calculated results, so you can put a lookup result, a calculation and a label next to each other with a single formula.
The arguments
Each array can be a range, an array constant, or the output of a formula. =HSTACK(A2:A4,C2:C4) returns the product names and prices from columns that aren't next to each other. The array on the left of the formula is the leftmost in the result.
Adding a calculated column
HSTACK is how you return a table and a column that you calculate in the same formula, without a helper column in the data:
=HSTACK(A2:A4,B2:B4*C2:C4)
The second argument multiplies Units by Price for every row at once and returns the revenue column. The first returns the names. Together they form a two-column array that spills from one cell.
Numbering a list
Pair a list with SEQUENCE to number it: =HSTACK(SEQUENCE(ROWS(A2:A4)),A2:A4). The numbers adjust whenever the list gets longer or shorter.
When the heights differ
The result is as tall as the tallest array. A shorter array is padded with #N/A at the bottom. =HSTACK(A2:A4,E2:E3) has three rows because column A has three, and the second column gets #N/A in its third row. Use IFNA to replace the padding: =IFNA(HSTACK(A2:A4,E2:E3),"").
HSTACK, CHOOSECOLS and VSTACK
CHOOSECOLS picks columns out of one array. HSTACK builds one array from separate pieces, so the two often appear together: HSTACK to bring the pieces together, CHOOSECOLS to trim the combined result. VSTACK does the same job vertically. The pair lets you build any table shape: stack the rows, then join the columns.
Notes
Use it to reorder columns of a table you can't move: =HSTACK(C2:C4,A2:A4) puts column C first. Blank cells come back as 0. The result spills to the right and down, so the cells it needs must be empty or you get #SPILL!. See FILTER for spill ranges and the # operator.
HSTACK needs Microsoft 365, Excel 2024 or later, or Excel for the web. In older versions the formula returns #NAME?.