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
Ensure each input array has the same number of rows.
-
2
List arrays as HSTACK(a, b, c) in left-to-right order.
-
3
Leave wide spill space to the right of the formula.
-
4
Pad shorter lists with IF or MAKEARRAY only when intentional.
-
5
Combine with FILTER on each block first if widths differ in meaning.
-
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.
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
Advanced Coding in Google Sheets for Programmers
Tips to Navigating Thousands of Lines of Code In Apps Script
Hacks You Might Not Know
Spreadsheet Automation 101: Functions
Related blog posts
Guides that explain HSTACK in more depth.
Explore Coding in Google Sheets
Did you know you can actually code in Google Sheets?
Read post →Spreadsheets Explained over 5 Levels of Difficulty
Master Google Sheets from simple text input to complex operations with our FREE tutorials, templates, and tools! Unleash the full power of spreadsheets now!
Read post →Why Should I Code in Google Sheets?
Automate repetitive tasks, such as data entry, calculations, and formatting in Google Sheets.
Read post →Related terms
VSTACK
VSTACK stacks arrays on top of each other into one taller table. Combine regional exports, monthly snapshots, or FILTER results with the same columns without manual paste below last row.
Read guide →TOCOL
TOCOL converts a range into a single column. You can choose whether it reads down each column first or across rows first. It replaces manual paste-special transpose chains when reshaping blocks for UNIQUE or FILTER.
Read guide →TOROW
TOROW flattens a range into a single row spill. Like TOCOL but horizontal, it helps build header arrays, SPARKLINE source rows, and inputs for functions that expect one horizontal vector.
Read guide →FLATTEN
FLATTEN converts a two-dimensional range into a single column, reading across rows then down. It is useful after SPLIT or when you need every value from a block in one list for UNIQUE, COUNTIF, or mail merge prep.
Read guide →Done reading about HSTACK?
Membership unlocks 600+ 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.