Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Appends arrays horizontally and in sequence to return a larger array.

Syntax

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

The HSTACK function syntax has the following argument:

array    The arrays to append.

Remarks

HSTACK returns the array formed by appending each of the array arguments in a column-wise fashion. The resulting array will be the following dimensions:

  • Rows    The maximum of the row count from each of the array arguments.

  • Columns    The combined count of all the columns from each of the array arguments.

Errors

If an array has fewer rows than the maximum width of the selected arrays, Excel returns a #N/A error in the additional rows. Use HSTACK inside the IFERROR function to replace #N/A with the value of your choice.

Examples

Copy the example data in the following table and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data.

Horizontally appends two simple arrays in sequence so that the results are one array.

Data

A

B

C

AA

BB

CC

D

E

F

DD

EE

FF

Formula

=HSTACK(A2:C3,E2:G3)

Horizontally appends three arrays in sequence so that the results are one array of three rows and six columns with a #N/A error to fill in empty array elements.

Data

1

2

A

B

X

Y

3

4

C

D

5

6

Formulas

=HSTACK(A2:B4,C2:D3,E2:F2)

Horizontally appends three arrays in sequence so that the results are one array of three rows and six columns with a #N/A error to fill in empty array elements. Because cell F3 is originally blank, a 0 value is added to cell F7.

Data

1

2

A

B

C

#VALUE!

3

4

D

E

F

5

6

Formulas

=HSTACK(A2:B4,C2:D3,E2:F3)

See Also

Guidelines and examples of array formulas

VSTACK function

CHOOSEROWS function

CHOOSECOLS function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×