# Excel HSTACK function

## Summary

The Excel HSTACK function is designed to combine arrays or ranges horizontally into a single array. It appends each subsequent array to the right of the previous one. This function is particularly useful for consolidating data from multiple arrays or ranges into a single horizontal layout, facilitating analysis and comparison across different data sets.
##### Syntax
```				```
=HSTACK(array1, [array2], ...)
```
```
• array1: The first array or range to combine
• array2: [Optional] The second array or range to combine, and so on
##### Return value
A single combined array or range, extending horizontally.

## How to use

Use HSTACK to combine two or more arrays or ranges horizontally. Each additional array or range specified in the function arguments is placed to the right of the preceding one. The function dynamically adjusts to changes in the data of the combined arrays or ranges.

## Examples

##### Simple HSTACK
Combining Two Horizontal Ranges: Horizontally stacking two ranges:
```				```
=HSTACK(B3:D3, E3:G3)
```
```
This formula horizontally combines the ranges B3:D3 and E3:G3 into one continuous horizontal array.
##### HSTACK with Multiple Rows
Stacking Ranges with Multiple Rows: Combining multiple row ranges horizontally:
```				```
=HSTACK(A1:A3, B1:B3, C1:C3)
```
```
Here, HSTACK combines three vertical ranges (A1:A3, B1:B3, C1:C3) side by side, forming a wider array that spans horizontally.
##### HSTACK with Array Constants

Using HSTACK with Array Constants: Combining an array constant with a range:

```				```
=HSTACK({"Red", "Blue", "Green"}, B2:D2)
```
```
This formula horizontally stacks an array constant of three colors with the range B2:D2.
##### HSTACK for Data Consolidation
Consolidating Multiple Data Columns: To consolidate data from various columns into a single row:
```				```
=HSTACK(F2:F10, G2:G10, H2:H10)
```
```
This formula combines data from columns F, G, and H into a single row, aligning the data horizontally.
##### HSTACK with Different Sizes
Handling Arrays of Different Sizes: Combining arrays of different row counts:
```				```
=HSTACK(B2:B5, C2:C3)
```
```
In this example, HSTACK combines a taller array (B2:B5) with a shorter one (C2:C3). The shorter array will be padded with #N/A errors for the unmatched rows.