ID EN
#Dynamic array

HSTACK

Excel Functions

Combine ranges or arrays horizontally

Syntax

EXCEL
=HSTACK(array1, [array2], ...)

Arguments

Parameter Description
array1 The first array or range to combine.
array2 [optional] The second array or range to combine.

Return Value

A single combined range or array

Details

The HSTACK function combines arrays horizontally into a single array. Each subsequent array is appended to the right of the previous array. The result from HSTACK is a single array that spills onto the worksheet into multiple cells. HSTACK works equally well for ranges on a worksheet or in-memory arrays created by a formula. The output from HSTACK is fully dynamic. If data in any given array changes, the result from HSTACK will update immediately. Use HSTACK to combine ranges horizontally and VSTACK to combine ranges vertically. HSTACK stacks ranges or arrays horizontally. In the example below, the range B3:D3 is combined with the range B6:C6. Each subsequent range/array is appended to the right of the previous range/array. The formula in F3 is: Ranges may include multiple rows, as seen be

Examples

Basic usage

HSTACK stacks ranges or arrays horizontally. In the example below, the range B3:D3 is combined with the range B6:C6. Each subsequent range/array is ap

EXCEL
=HSTACK(B3:D3,B6:C6)
Basic usage

Ranges may include multiple rows, as seen below. The formula in F3 is:

EXCEL
=HSTACK(B3:B5,D3:D5)
Range with array

HSTACK can work interchangeably with both arrays and ranges. In the worksheet below, we combine the array constant {"Red";"Blue";"Green"} with the ran

EXCEL
=HSTACK({"Red";"Blue";"Green"},B2:B4)
Arrays of different sizes

When HSTACK is used with arrays of different sizes, the smaller array will be expanded to match the size of the larger array. In other words, the smal

EXCEL
=HSTACK(B5:B8,D5:D6)
Arrays of different sizes

By default, the cells used for padding will display the #N/A error. One option for trapping these errors is to use the IFERROR function. The formula i

EXCEL
=IFERROR(HSTACK(B5:B8,D5:D6),"")

See Also

VSTACK TRIMRANGE