What is HSTACK in Google Sheets?

HSTACK appends arrays horizontally so columns sit side by side in one spilled table. It replaces fragile copy-paste when combining QUERY outputs, IMPORTRANGE blocks, or calculated columns with matching row heights.

When to use it

Use HSTACK to merge two or more column blocks with the same row count into one wide report.

When to skip it

Skip HSTACK when you need vertical stacking. VSTACK joins rows downward instead.

How it works

  1. 1

    Ensure each input array has the same number of rows.

  2. 2

    List arrays as HSTACK(a, b, c) in left-to-right order.

  3. 3

    Leave wide spill space to the right of the formula.

  4. 4

    Pad shorter lists with IF or MAKEARRAY only when intentional.

  5. 5

    Combine with FILTER on each block first if widths differ in meaning.

  6. 6

    Document column order for teammates reading the wide export.

Examples in Google Sheets

Merge name and metrics

=HSTACK(A2:C, E2:F) joins identity columns with KPI columns when row counts align.

IMPORT plus calc

=HSTACK(IMPORTRANGE(id, "Data!A:C"), D2:D) adds a local calculated column beside imported fields.

Dual QUERY

=HSTACK(QUERY(t1), QUERY(t2)) places two query outputs side by side for comparison.

Build this without starting from a blank cell

Use a Better Sheets tool for HSTACK, then watch a walkthrough when you want the full pattern.

Better Sheets resources

Common mistakes

  • Row count mismatch causing #VALUE! or misaligned data.
  • HSTACK when VSTACK was needed to append below.
  • Stacking unrelated tables without shared keys for sanity checks.
  • Spill blocked by formatted empty cells to the right.
  • Assuming HSTACK dedupes or sorts; it only concatenates columns.

Frequently asked questions

HSTACK vs {A,B} notation?
Curly array syntax also joins side by side. HSTACK is explicit and accepts dynamic arrays.
Different row counts?
HSTACK requires matching heights. Pad or trim first.
HSTACK with headers?
Include header rows in each block if you want them in output.
HSTACK and QUERY?
Common to place multiple QUERY spills beside each other.
Why misaligned rows?
One source filtered rows without matching the other block.
HSTACK limit?
Very wide stacks are hard to read. Consider a single QUERY SELECT instead.
HSTACK vs JOIN?
JOIN merges text in one cell. HSTACK keeps separate columns.

Related Tutorials

Watch how HSTACK works

Browse more tutorials
Advanced Coding in Google Sheets for Programmers

Advanced Coding in Google Sheets for Programmers

Add a Custom Menu Create Native-like Functions Get URL and Sheet ID's vi...
Tips to Navigating Thousands of Lines of Code In Apps Script

Tips to Navigating Thousands of Lines of Code In Apps Script

Find out how I use Apps Script built in features to code very quickly an...
Hacks You Might Not Know

Hacks You Might Not Know

These are simple spreadsheet hacks you might not know about. Simple inte...
Spreadsheet Automation 101: Functions

Spreadsheet Automation 101: Functions

Get introduced to Apps Script functions and functions syntax. Learn how ...

Related blog posts

Guides that explain HSTACK in more depth.

Browse the blog

Related glossary terms

Done reading about HSTACK?

Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.

Need this once

Jump to a free tool or a single tutorial for this topic.

Learning Sheets for real

Unlock the full library, generators, and templates with membership.