VSTACK in Google Sheets: How to Combine Ranges
In this article
- Why People Search for VSTACK in Google Sheets
- How to Stack Ranges Vertically in Google Sheets
- Using FILTER to Stack Only Non-Empty Rows
- Stacking with QUERY for More Control
- Common Errors and How to Fix Them
- VSTACK vs. Curly Braces: Key Differences from Excel
- Alternatives: TOCOL, FLATTEN, and Apps Script
- Frequently Asked Questions
The direct answer: Google Sheets does not have a function named VSTACK. The VSTACK function is exclusive to Microsoft Excel (Microsoft 365 and Excel 2024), and in Google Sheets you combine ranges vertically using the curly-brace array syntax, like ={A1:A10;B1:B10} or the FILTER and QUERY functions. If you are looking for the Excel behavior of stacking arrays on top of each other, the Google Sheets equivalent is simply writing the ranges inside curly braces with a semicolon between them.
Why People Search for VSTACK in Google Sheets
Most people searching for “VSTACK in Google Sheets” have recently switched from Excel or have followed an Excel tutorial that uses VSTACK. In Excel 365, VSTACK takes multiple ranges and stacks them vertically into one continuous array. For example, =VSTACK(A1:A10, C1:C10) returns 20 rows. Google Sheets does not have this named function, but it has had array-literal syntax since 2013, which accomplishes the exact same result. The confusion is common because the two spreadsheet apps have different naming conventions for array operations: Excel uses dedicated functions (VSTACK, HSTACK, TOCOL, TOROW), while Google Sheets uses braces and operators.
How to Stack Ranges Vertically in Google Sheets
To combine two or more columns or rows on top of each other in Google Sheets, use the array literal with a semicolon. The semicolon means “stack vertically.” A comma means “place side by side” (like Excel’s HSTACK).
- Stack two columns:
={A1:A5;B1:B5}– this returns a single column with 10 rows: first A1:A5, then B1:B5. - Stack three columns:
={A1:A5;B1:B5;C1:C5} - Stack entire columns:
={A:A;C:C}– but be careful; this includes all 1,000+ rows, including empty ones. - Stack rows side-by-side (HSTACK equivalent):
={A1:C1,D1:F1}– comma combines horizontally.
Enter the formula in a single cell. Google Sheets will automatically spill the results into the rows below. If there is any data in the cells where the result would spill, you will see a #REF! error.
Using FILTER to Stack Only Non-Empty Rows
A common problem with the simple brace method is that it includes blank cells. If you have data in A1:A5 and B1:B5 but B3 is empty, the stacked result will contain a blank row. To skip blanks, wrap each range in FILTER:
={FILTER(A1:A5, A1:A5<>""); FILTER(B1:B5, B1:B5<>";")}
This returns only non-empty cells from each range, stacked vertically. You can also use FILTER to stack based on a condition, such as only rows where column C equals “Yes”.
Stacking with QUERY for More Control
If you need to stack multiple ranges and also remove headers or sort the result, QUERY is the most powerful tool. For example, to stack two ranges that both have a header row, and then remove the duplicate headers:
=QUERY({A1:C5;E1:G5}, "select * where Col1 is not null", 1)
Here the 1 tells QUERY that the first row of the combined array is a header. QUERY will use the first range’s headers and drop the second range’s header row. If you want no headers at all, use 0 as the third argument.
Common Errors and How to Fix Them
When you try to stack ranges in Google Sheets, you may run into these errors:
- #VALUE! – Mismatched row counts: When you use a comma (horizontal stacking), all ranges must have the same number of rows. When you use a semicolon (vertical stacking), all ranges must have the same number of columns. For example,
={A1:A5;B1:B3}fails because the first has 5 rows and the second has 3. - #REF! – Overlapping ranges: If the formula is in a cell that is included in the range you are stacking, you get a circular reference. For example, putting
={A1:A10}in cell A1 will fail. - #N/A – Mismatched column counts: If you try to stack a 2-column range with a 3-column range vertically, you get an error. Use
QUERYor add blank columns to make them match.
VSTACK vs. Curly Braces: Key Differences from Excel
Excel’s VSTACK function and Google Sheets’ brace syntax behave similarly but have some differences:
- Argument separation: In Excel, VSTACK uses commas between ranges (
=VSTACK(A1:A5,B1:B5)). In Google Sheets, you use a semicolon inside braces (={A1:A5;B1:B5}). - Spill behavior: Both spill results automatically, but Excel shows a blue border around the spilled array. Google Sheets just fills the cells.
- Dynamic arrays: Excel’s VSTACK works with dynamic arrays that resize. Google Sheets braces also work with dynamic arrays, but you must use
FILTERorSEQUENCEto create them on the fly. - Error handling: Excel’s VSTACK will return a
#VALUE!error if ranges have different column counts. Google Sheets does the same, but the error message is often less descriptive.
Alternatives: TOCOL, FLATTEN, and Apps Script
If you need to stack ranges but also convert them into a single column (flattening), Google Sheets has a FLATTEN function. For example, =FLATTEN(A1:C3) takes a 3x3 grid and returns a single column of 9 values, reading row by row. Excel’s TOCOL does the same but is not available in Sheets. For more complex stacking (like interleaving rows from two ranges), you would need an Apps Script custom function. Here is a simple script that mimics VSTACK:
function VSTACK(...ranges) {
const output = [];
ranges.forEach(range => {
range.forEach(row => output.push(row));
});
return output;
}
To use it, go to Extensions > Apps Script, paste the code, save it, and then call =VSTACK(A1:A5,B1:B5) in your sheet. Note that Apps Script functions recalculate only when the sheet changes, not in real time.
Frequently Asked Questions
Does Google Sheets have VSTACK? No. The VSTACK function is only in Microsoft Excel (Microsoft 365 and Excel 2024). In Google Sheets, use the array literal with a semicolon: ={A1:A10;B1:B10}.
How do I stack two columns without blanks? Use FILTER inside the braces: ={FILTER(A1:A10,A1:A10<>"");FILTER(B1:B10,B1:B10<>"")}. This removes empty cells from each column before stacking.
Can I stack ranges from different sheets? Yes. Use the sheet name with an exclamation mark: ={Sheet1!A1:A5;Sheet2!A1:A5}. If the sheet name has spaces, put it in single quotes: ={'My Sheet'!A1:A5;'Other Sheet'!A1:A5}.
Why do I get a #VALUE! error when stacking? Most likely because the ranges have different numbers of columns. For vertical stacking (semicolon), every range must have the same number of columns. Check that each range has the same width.
Is there a way to stack rows instead of columns? Yes. To stack rows vertically (i.e., put row 1 on top of row 2), use the same semicolon syntax but with row ranges: ={A1:C1;A2:C2}. This returns a 2-row by 3-column array.
Can I use VSTACK in Google Sheets on mobile? The mobile app uses the same formula engine, so the brace syntax works. Just type the formula manually, as the mobile interface does not have a function wizard for array literals.