Google Sheets Guide · Prompt: “Import rows from another Google Sheet and keep only rows where column 3 equals "Active"”
Filter Rows Across Spreadsheets with IMPORTRANGE + QUERY
Verified by LiveFormulaLab Engineering Team • Updated November 2026
Pull only matching rows from another spreadsheet using IMPORTRANGE wrapped inside QUERY or FILTER. Copy syntax and view SQL equivalent.
Verified Google Sheets Syntax
=QUERY(IMPORTRANGE("SHEET_URL_OR_ID", "Data!A1:D500"), "SELECT * WHERE Col3 = 'Active'", 1)How This Formula Works (Step-by-Step)
Importing an entire external sheet and filtering locally keeps data pipelines modular without exposing raw tabs.
Step 1: Wrap IMPORTRANGE inside QUERY so Google Sheets treats the imported range as a virtual table.
Step 2: Use Col1, Col2, Col3 notation inside WHERE because IMPORTRANGE returns a computed array rather than local cell letters.
Formula Syntax & Arguments Breakdown
Nests IMPORTRANGE inside QUERY so rows from an external Google Spreadsheet are filtered remotely in memory before rendering into the destination sheet.
| Argument / Clause | Requirement | Data Type | Role & Behavior |
|---|---|---|---|
spreadsheet_url ("SHEET_URL_OR_ID") | Required | URL / Spreadsheet ID | Full URL or short ID string of the source Google Sheet containing the master dataset. |
range_string ("Data!A1:D500") | Required | Sheet & Range String | Tab name and cell bounds in the source file quoted as a single string. |
query ("SELECT * WHERE Col3 = 'Active'") | Required | Col-Index Query | Must use Col1, Col2, Col3 references rather than column letters because IMPORTRANGE returns a virtual array. |
3 Real-World Use Cases
- Syncing only active client deliverables from an agency master tracker to a client portal sheet.
- Pulling approved budget lines from Finance into department-specific tabs.
- Aggregating regional sales sheets into one executive rollup workbook.
Cross-Platform Equivalents
- Excel
=FILTER(Data!A2:D500, Data!C2:C500="Active")- SQL
SELECT * FROM external_clients WHERE status = 'Active';- Python Pandas
external_df[external_df['Status'] == 'Active']
Common Mistakes & Pro Tips
Pitfalls & How to Fix Them
Mistake: Using WHERE C = 'Active' inside QUERY(IMPORTRANGE(...)) throws #VALUE! ("Unable to parse query string: NO_COLUMN: C").
Fix: Always use Col1, Col2, Col3 (case-sensitive capital C) when querying IMPORTRANGE results.
Mistake: Nesting IMPORTRANGE directly inside QUERY on a brand-new workbook hides the "Allow access" permission prompt inside #REF!.
Fix: Run a bare =IMPORTRANGE("URL", "Data!A1:A2") in a temporary cell first, click "Allow access", then wrap it in QUERY.
Mistake: Pulling A1:Z50000 across ten tabs slows down every calculation cycle.
Fix: Select only the required columns in QUERY ("SELECT Col1, Col3, Col4") and cap row ranges to active sizes.
Engineering Pro Tips
- Use only the Spreadsheet ID (the string between /d/ and /edit) inside IMPORTRANGE for cleaner, shorter formulas.
- Combine multiple remote tabs in one QUERY using stacked arrays: QUERY({IMPORTRANGE(id1,"A2:D"); IMPORTRANGE(id2,"A2:D")}, "SELECT * WHERE Col1 IS NOT NULL").
- Add LIMIT 100 at the end of your QUERY when previewing massive external sheets.
Frequently Asked Questions
- Why must I use Col3 instead of C when filtering IMPORTRANGE?
- Whenever QUERY reads an array returned by another function (like IMPORTRANGE or {}), column letters are unavailable and Col1, Col2, Col3 must be used.
- Why do I see #REF! "You need to connect these sheets"?
- Run a bare =IMPORTRANGE(...) once in a blank cell and click "Allow access" before nesting it.
- Can I use FILTER directly with IMPORTRANGE?
- You would have to call IMPORTRANGE twice (once for data, once for criteria), making QUERY much faster.
Related Formulas & Guides
- Extract Domain Name From URLs in Google Sheets with REGEXEXTRACT — Extract clean domain hostnames from full HTTP/HTTPS URLs in Google Sheets using REGEXEXTRACT. Copy the verified formula and test live.
- Auto-Expanding Running Balance in Google Sheets (SCAN + LAMBDA) — Create an automatic running balance column in Google Sheets with SCAN and LAMBDA or SUMIF ROW. Never drag formulas again.
- Split and Reformat Comma-Separated Values in Google Sheets — Split comma-separated tags or reformat delimited lists cleanly in Google Sheets using SPLIT, TRIM, and TEXTJOIN. Test live in our grid.
- Count Distinct Values with Criteria Using COUNTUNIQUEIFS — Count distinct users, orders, or accounts meeting multiple filter conditions in Google Sheets using COUNTUNIQUEIFS and live examples.