Array

HSTACK Formula

Horizontally stacks two or more arrays side by side, appending each array as additional columns to the right of the previous one. HSTACK is ideal for building wide tables from separate column groups, adding calculated columns next to source data, or combining related data sets horizontally.

Syntax

HSTACK(array1, [array2, ...])
ParameterDescription
array1 Parameter of the HSTACK function.
[array2 (Optional.) Parameter of the HSTACK function.
...] Parameter of the HSTACK function.
Try HSTACK in Viztab — free, no signup

Examples

Combine name and score columns

Formula
=HSTACK(A1:A20, D1:D20)
Places the names column next to the scores column, creating a 2-column table even though the source columns aren't adjacent.

Add a calculated column

Formula
=HSTACK(A1:C10, A1:A10*B1:B10)
Appends a revenue column (quantity * price) as a 4th column next to the original 3-column data.

Combine data from two sources

Formula
=HSTACK(Sheet1!A1:B20, Sheet2!A1:C20)
Creates a 5-column table by placing Sheet2's 3 columns to the right of Sheet1's 2 columns.

Common Errors

#N/A

Arrays have different row counts. Shorter arrays are padded with #N/A at the bottom.

#SPILL!

The output range is blocked by existing non-empty cells.

Tips

Build dashboards without helper columns

Use HSTACK to assemble exactly the columns you need, from any location, into one view. No intermediate columns required.

Match row counts

HSTACK pads shorter arrays with #N/A at the bottom. If that's a problem, use EXPAND to pad with a specific value first, or ensure arrays have equal row counts.

Combine with CHOOSECOLS

=CHOOSECOLS(HSTACK(range1, range2), 1, 4, 5) stacks arrays horizontally then picks specific columns from the combined result.

Try HSTACK in Viztab

Import your data and use HSTACK with 370+ other formulas. No signup required.

Open Viztab

Related Formulas