HSTACK

Join two or more ranges side by side to build one wider array in a single formula.

|
Excel 2021+
|
Google Sheets Supported

Spreadsheet editor

Syntax

=HSTACK(array1, [array2], ...) Returns: Array

Arguments

Argument Required Description
array1 Yes The first range or array to join. This forms the left block of the combined result.
array2, ... No Extra ranges or arrays to append to the right of array1, in the order you list them. You can keep adding more, each one sitting next to the last.

About

HSTACK takes several ranges or arrays and lines them up next to each other, returning a single combined array that spills into the cells to the right of your formula. Think of it as a quick way to push separate blocks of data together into one wide table without copying and pasting columns. List the ranges in the order you want them placed, and HSTACK joins them left to right.

Use it when related data sits in different spots and you want it side by side: a column of names next to a column of scores, two reports you want lined up for comparison, or several lists you want laid out across one row of columns. Because the output is a live array, it refreshes on its own whenever the source ranges change, so you never have to rebuild the combined table by hand. Pair it with SORT or FILTER to organize the joined result, or with CHOOSECOLS to pick out the columns you actually need.

HSTACK works in Microsoft 365, Excel for the web, and Excel 2021 and later. If your ranges have different heights, HSTACK matches the tallest one and fills the extra cells with #N/A. To stack ranges top to bottom instead of side by side, use its companion VSTACK, and to grab a set number of rows or columns from the result, use TAKE.

Examples

Watch #N/A appear from mismatched heights

See what happens when you join a three-row range next to a two-row range. HSTACK matches the taller block and pads the gap with #N/A. Add a third name and update the cell range in the HSTACK function to clear the error.

Spreadsheet editor

Get the column order right

Notice how Price lands on the left because its range is listed first. Swap the arguments to put Product back in front and see the columns flip.

Spreadsheet editor

Join two columns, then keep the winners

Combine the rep and sales columns side by side and pass the result straight to FILTER to keep only the big deals. Change a sales figure and watch the shortlist update on its own.

Spreadsheet editor

Watch out for

#N/A from mismatched heights

When the ranges you join have different numbers of rows, HSTACK matches the tallest one and pads the gaps with #N/A.

Make sure every range has the same number of rows, or wrap the formula in IFERROR to swap the #N/A padding for a blank.

Spill range is blocked

HSTACK needs empty cells to the right of the formula to fill. If anything is in the way, you get a #SPILL! error instead of the joined array.

Clear the cells beside and below the formula so the combined result has room to spill.

Not available in older Excel

HSTACK only exists in Microsoft 365 and Excel 2021 and later, so it returns a #NAME? error in Excel 2019 and earlier.

On older versions, place each range next to the last by hand, or rebuild the table with helper columns.

Wrong column order

HSTACK adds ranges in the exact order you list them, so a label or key column can end up on the wrong side.

List the range you want on the left first, then each block to the right in the order it should appear.

Tips & notes

HSTACK joins ranges left to right; its companion VSTACK stacks them top to bottom. The result columns equal the total columns of every range added together, and the height matches the tallest range. Because the output is a live array, leave room to the right of the formula and let it spill on its own.

Common questions

What is the difference between HSTACK and VSTACK?

HSTACK joins ranges horizontally, side by side, to make a wider array. VSTACK stacks ranges vertically, one below the other, to make a taller one.

Why does HSTACK return #N/A in some cells?

That happens when the joined ranges have different heights. HSTACK matches the tallest range and fills the missing cells with #N/A. Give every range the same number of rows to avoid it.

Can I sort or filter the result of HSTACK?

Yes. Wrap HSTACK inside SORT or FILTER to organize the combined array in the same formula.

Does HSTACK work in Excel 2019 or Google Sheets?

It needs Microsoft 365 or Excel 2021 and later, so it is not in Excel 2019. Google Sheets supports HSTACK.