Excel Tutorials – HSTACK



Excel HSTACK

Stop squinting at columns. Start stacking stuff sideways.

So What the Heck Is HSTACK?

Okay, imagine you’ve got two lists. Maybe one is first names, the other is last names. You want them side by side — like a proper table. Normally you’d copy-paste, or use some janky INDEX/MATCH. But HSTACK is like a glue gun for arrays. It stacks things horizontally — left to right — into one big range.

“HSTACK takes a bunch of ranges or arrays and just… smooshes them together side-by-side. Like putting two books next to each other on a shelf. You don’t even need to know how many rows there are — it figures it out.”

The Basic Recipe

=HSTACK(array1, array2, )

That’s it. You give it two or more chunks of data, and it glues them together left-to-right. All arrays need to have the same number of rows, otherwise Excel throws a fit (it’ll give you a #VALUE! error). We’ll talk about that later.

Easy Warm-Up

Example 1: First Names + Last Names = Full Names

You’ve got first names in column A, last names in column B. You want them together, but not concatenated — you want them as two separate columns side-by-side. HSTACK is your buddy.

Data:

A1:A3 = {“Taylor”; “Jordan”; “Avery”}
B1:B3 = {“Swift”; “Peele”; “Brooks”}

Formula:

=HSTACK(A1:A3, B1:B3)

Result: A two-column range: Taylor | Swift / Jordan | Peele / Avery | Brooks. Boom. Instant table.

Notice I didn’t say “copy the formula down.” HSTACK spills the whole thing at once. Dynamic arrays, baby.

Example 2: Scores + Grades (Quick Dashboard)

You’ve got scores in one column, and you already calculated grades with that LAMBDA we learned earlier. Now you want them side-by-side so you can see both at once.

Data: Scores in D2:D6, grades in E2:E6 (from your GRADE function).

Formula:

=HSTACK(D2:D6, E2:E6)

Now you’ve got a clean little table: score in the left column, letter grade on the right. No copy-paste, no VLOOKUP to build a table — just HSTACK and done.

Example 3: Static Headers + Dynamic Data

You want to add headers to your data without typing them in the sheet. HSTACK can merge a static array (like {“Name”,”Score”}) with your data.

Data: Names in F2:F4, scores in G2:G4.

Formula:

=HSTACK({“Name”,”Score”}, F2:F4, G2:G4)

Result: A table with “Name” and “Score” as headers, then your data right below. No manual typing, no merging cells — just pure stacking.

Medium Level Up

Example 1: Combine Different Arrays (Same Rows)

You’ve got a list of product IDs, a list of prices, and a list of quantities. You want them all in one wide range — maybe for an invoice or a report.

Data: Product IDs in I2:I10, Prices in J2:J10, Quantities in K2:K10.

Formula:

=HSTACK(I2:I10, J2:J10, K2:K10)

Now you’ve got three columns side-by-side. But wait — you also want a “Total” column (Price * Qty). You can do that inside HSTACK:

=HSTACK(I2:I10, J2:J10, K2:K10, J2:J10 * K2:K10)

Four columns: ID, Price, Qty, Total. All in one go. No helper columns, no dragging formulas down.

Example 2: Filter Before You Stack

You only want to stack rows where a condition is met. HSTACK works perfectly with FILTER.

Data: Names in L2:L20, Scores in M2:M20. You only want to show students who passed (score ≥ 60).

Formula:

=HSTACK(
FILTER(L2:L20, M2:M20 >= 60),
FILTER(M2:M20, M2:M20 >= 60)
)

This is basically “show me passing students and their scores.” Both filters use the same condition, so the rows match perfectly. Boom — dynamic report.

Example 3: HSTACK + SORT (Put It in Order)

You want to stack two columns and sort them by one of the columns. Combine HSTACK with SORT.

Data: Employee names in N2:N15, salaries in O2:O15.

Formula:

=SORT(
HSTACK(N2:N15, O2:O15),
2, // sort by the second column (salary)
-1 // descending order (highest first)
)

Now you’ve got a sorted list of employees from highest salary to lowest, with names and salaries side-by-side. One formula, zero manual sorting.

Hard Now We’re Cooking

Example 1: HSTACK with CHOOSECOLS (Re-arrange Columns)

You’ve got a big table, but you only want a few columns, and you want them in a specific order. CHOOSECOLS picks columns, HSTACK arranges them.

Data: A big range — say A2:D100 (Name, Age, City, Salary). You want Name, Salary, City in that order.

Formula:

=HSTACK(
CHOOSECOLS(A2:D100, 1),
CHOOSECOLS(A2:D100, 4),
CHOOSECOLS(A2:D100, 3)
)

You just reordered your columns without touching the original data. And if you add rows, it updates automatically.

Example 2: HSTACK + VSTACK (Two‑Dimensional Glue)

Now we’re getting wild. HSTACK stacks sideways, VSTACK stacks downward. Together, they can build whole tables from pieces.

You want a table with headers on top, then data, then a summary row at the bottom.

Data: Names in P2:P10, Sales in Q2:Q10.

Formula:

=VSTACK(
HSTACK({“Name”,”Sales”}),
HSTACK(P2:P10, Q2:Q10),
HSTACK({“Total”}, SUM(Q2:Q10))
)

Boom: a full table with headers, data, and a total row. All in one formula, all dynamic. This is Excel witchcraft and I love it.

Example 3: HSTACK with LET (Readable, Clean, Beautiful)

When you start stacking multiple things, formulas get ugly. LET lets you name intermediate chunks so you can actually read what you wrote.

You’ve got product data, and you want to stack: Product ID, Name, Price, and a calculated column (Price * 1.1 for tax).

Data: ID in R2:R50, Name in S2:S50, Price in T2:T50.

Formula:

=LET(
ids, R2:R50,
names, S2:S50,
prices, T2:T50,
taxed, prices * 1.1,
HSTACK(ids, names, prices, taxed)
)

Now you can see exactly what’s happening. ids, names, prices, taxed — it’s like reading a recipe instead of a wall of text. And if you need to change the tax rate, you update it in one place.

💡 PRO TIP

The Row Count Rule: All the arrays you give to HSTACK must have the exact same number of rows. If one has 10 rows and another has 12, Excel goes “nope” and gives you #VALUE!. Use FILTER or TAKE/DROP to trim them if needed.

Quick Rules (So You Don’t Cry)

  • Same row count. All arrays must have the same number of rows. If not, #VALUE! error. Check your data.
  • It spills. HSTACK returns a dynamic array — it’ll fill as many columns as you give it and as many rows as the tallest array. But the row count must match.
  • You can stack arrays, ranges, even single values. =HSTACK(42, A1:A5) works — 42 repeats for every row.
  • Use with VSTACK for 2D magic. VSTACK stacks down, HSTACK stacks across. Together they build whole sheets.
  • LET is your friend. When you have 4+ arrays, use LET to name them. Your future self will thank you.

Your Turn — Go Play

Open Excel and try these. Don’t peek at the answers — figure it out. You’ll remember it way better.

  1. Stack two columns of your own data. Any two lists. Just HSTACK them and watch the magic.
  2. Add a header row using {“Header1″,”Header2”} stacked with your data.
  3. Filter first, then stack. Use FILTER to get only rows where a condition is true, then HSTACK those filtered columns.
  4. Build a mini dashboard with HSTACK, VSTACK, and LET. Include a total row.

If you can do all four without throwing your laptop out the window, you’ve mastered HSTACK. Go forth and stack things.

HSTACK is one of those functions that seems simple, but once you start using it, you find a million places where it makes your life easier. It’s like a Swiss Army knife for columns. Seriously — go stack something right now.

Leave a Reply