You can query multiple sheets in Google Sheets using the QUERY function with {} curly braces to combine ranges, or by using QUERY with IMPORTRANGE for separate files. The simplest method is to stack ranges from the same spreadsheet inside curly braces with semicolons, then wrap them in QUERY.
Why Query Multiple Sheets?
When your data lives in separate tabs—like monthly sales reports, department lists, or project trackers—you often need to analyze it as one unified dataset. The QUERY function is Google Sheets’ built-in tool for filtering, sorting, and aggregating data using a SQL-like language. By default, QUERY only reads a single range, but you can feed it a combined array of multiple sheets. This lets you run one query across all your tabs without copying data manually.
Method 1: Stacking Ranges with Curly Braces
If all your sheets are in the same spreadsheet, use curly braces to combine them vertically. The syntax is {Sheet1!A1:C; Sheet2!A1:C}—a semicolon stacks rows.
Example: You have sheets named Jan, Feb, and Mar, each with headers in row 1 and data starting in row 2. To get all rows where sales exceed $100:
=QUERY({Jan!A1:C; Feb!A1:C; Mar!A1:C}, "SELECT * WHERE C > 100", 1)
This assumes columns A, B, C contain Date, Item, and Sales. The third argument 1 tells QUERY that the first row of the combined range contains headers. If your sheets have different column orders, you must align them manually—QUERY will not reorder columns for you.
Method 2: Using IMPORTRANGE for Separate Files
When your data is in different spreadsheet files, use IMPORTRANGE to pull each range into a combined array. The syntax is {IMPORTRANGE("url_or_key", "Sheet1!A1:C"); IMPORTRANGE("url_or_key2", "Sheet2!A1:C")}.
Example:
=QUERY({IMPORTRANGE("https://docs.google.com/spreadsheets/d/abc123", "Jan!A1:C"); IMPORTRANGE("https://docs.google.com/spreadsheets/d/xyz789", "Feb!A1:C")}, "SELECT * WHERE Col3 > 100", 1)
Note: With IMPORTRANGE, you must use Col1, Col2, etc., instead of column letters in the query, because the array doesn’t carry original column labels. Also, you’ll be prompted to allow access to each external spreadsheet the first time you use it.
Method 3: Combining with VSTACK (Newer Function)
If you’re using a Google Workspace account or have the latest Sheets update, you can use VSTACK to stack ranges more cleanly. It works like the curly-brace method but is easier to read and can handle more complex combinations.
=QUERY(VSTACK(Jan!A1:C, Feb!A1:C, Mar!A1:C), "SELECT * WHERE Col3 > 100", 1)
VSTACK is available in Google Sheets as of 2022. It takes comma-separated ranges and stacks them vertically. This method is especially useful when you need to combine ranges with different numbers of columns—VSTACK will add #N/A for missing cells, but you can filter those out in the query.
How to Choose the Right Method
- Same spreadsheet, simple stack: Use curly braces
{}—fastest and no extra permissions. - Different spreadsheets: Use
IMPORTRANGEinside curly braces or withVSTACK. Be prepared for slower recalculations. - Dynamic ranges (e.g., new rows added often): Use
VSTACKwith full-column references likeJan!A:Cto avoid missing new data. - When you need to combine sheets with different column orders: You’ll need to reorder columns in each range manually—QUERY won’t do it automatically.
Common Problems and Fixes
Problem: “#VALUE!” error when combining ranges. This often happens when the ranges have different numbers of columns. QUERY requires all stacked ranges to have the same column count. Fix: Align the columns by selecting the same range size in each sheet, or use VSTACK which pads with #N/A.
Problem: Headers appear multiple times. If each sheet has headers, you’ll get duplicate header rows in the result. Fix: Use WHERE to exclude the header text, or set the third argument to 0 and include headers only in the first sheet.
Problem: Query returns wrong column names. When using IMPORTRANGE, you must reference columns as Col1, Col2, etc., not letters. For curly braces with same-spreadsheet sheets, you can use letters if you include the header row in the range.
Problem: Slow performance with large data. Combining many sheets with IMPORTRANGE can be slow. Consider using QUERY on each sheet separately and then combining the results, or use Google Apps Script to consolidate data once.
Frequently Asked Questions
Can I query all sheets in a spreadsheet without listing them? No, Google Sheets does not have a wildcard for sheet names. You must list each sheet range explicitly in the array. If you have many sheets, consider using Apps Script to generate the formula dynamically.
Does QUERY work with tabs that have spaces in their names? Yes, but you must wrap the sheet name in single quotes, like 'My Sheet'!A1:C. In the curly-brace array, that becomes {'My Sheet'!A1:C; 'Other Sheet'!A1:C}.
How do I combine sheets with different column orders? You can use QUERY with SELECT to reorder columns in each range before stacking. For example: {QUERY(Jan!A1:C, "SELECT A, C, B"); QUERY(Feb!A1:C, "SELECT A, C, B")}—this reorders columns to match.
Is there a limit to how many sheets I can combine? Google Sheets has a limit of 50,000 characters in a formula, so the number of sheets you can combine depends on the length of your sheet names and ranges. In practice, you can combine dozens of sheets, but performance may degrade.
Can I use QUERY with data from other sheets in the same file without braces? No, QUERY only accepts a single range reference. You must use braces or VSTACK to create an array of multiple ranges.
Alternatives to QUERY for Combining Data
If QUERY feels complex, you have other options:
- FILTER function: Combine with
VSTACKandFILTERto filter rows across sheets, but it’s less flexible for aggregation. - Google Apps Script: Write a script to read all sheets and output a combined dataset. This is best for complex transformations or scheduled updates.
- Data Connectors (BigQuery, etc.): For very large datasets, consider using BigQuery with a connector, which handles multi-table queries natively.
Each method has trade-offs in simplicity, performance, and maintenance. For most everyday tasks, the curly-brace or VSTACK method with QUERY is the sweet spot.
Related
- Windows Display Shortcut Keys: Full List
- Forecast Linear Excel: How to Use FORECAST.LINEAR
- Shortcut for Shutdown? The Real Windows Way
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Freeze Panes: Lock Rows and Columns TogetherYes. In Excel for Microsoft 365 on Windows, select the cell immediately below the rows and immediately to…
- How to Double Space in Word: Quick Step-by-Step GuideTo double-space text in Microsoft Word, select the text, then choose Home > Line and Paragraph Spacing >…
- How to Wrap Text in Google Sheets on Desktop and MobileTo wrap text in Google Sheets, select the cell or cells, then choose Format > Wrapping > Wrap.…
- Excel Shortcut to Insert a Row and Shift Cells DownIn Excel for Microsoft 365 on Windows, select the cell where the new space should begin and press…
- How to Change the Microsoft Outlook View and LayoutTo change the Microsoft Outlook view, open the View tab and select a layout or view option. In…
- How to Set Out of Office in the Outlook Mobile AppTo set an out-of-office reply in Outlook mobile, open the app’s Settings, select the email account, choose Automatic…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.