Note: The other languages of the website are Google-translated. Back to English

Excel HSTACK function

The HSTACK function combines multiple ranges or arrays horizontally into one large array, and each subsequent array will be added to the right of the preceding array.

Note: This function is only available in Excel for Microsoft 365 on the Insider channel.

HSTACK function VS. VSTACK function

The HSTACK function can be used to combine ranges horizontally, while the VSTACK function can be used to combine ranges vertically.

Syntax

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

Arguments

Array1 (required): The first range or array to append.
Array2,... (optional): The second and more ranges or arrays to append.

Remarks

1) The HSTACK function returns a single array that has the following dimensions:
The number of columns: It has as many columns as the sum of all the columns of the source arrays;
The number of rows: Equals to the maximum of the row count from each of the array arguments.
2) The resulting array automatically spills into as many cells as needed after entering the formula and pressing the Enter key;
3) The #N/A error value occurs if the given arrays have different rows. If you want to replace the #N/A error with the value you need, please embed the HSTACK function inside the IFERROR function. Such as:

=IFERROR(HSTACK(array1,array2,...),"")

Return value

It returns an array.

Example

As shown in the screenshot below, there are two ranges that need to be appended to a single range. You can apply the HSTACK function as follows to get it done.

Select a blank cell, such as C14 in this case, enter the following formula and press the Enter key to get the combined array.

=HSTACK(C6:F7,C10:F11)

Notes: If the ranges have different rows, #N/A error values will occur in the result array as shown in the screenshot below.

If you want to keep the cell blank when there is no value, you can apply the formula below to get it done.

=IFERROR(HSTACK(C6:F7,C10:F12),"")


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations