Google Sheets IMPORT Functions: IMPORTRANGE, IMPORTHTML, IMPORTXML
SheetHub4 min
Most spreadsheet data lives inside your sheet. But what if the data you need is in another sheet? Or on a website? Or in a CSV file on a server?
Google Sheets has four IMPORT functions that pull external data into your spreadsheet. They update automatically, so your data stays current without manual copying.
Importing data manually is error-prone. You copy, paste, format, repeat. If the source changes, your copy is outdated. IMPORT functions keep everything synced automatically.
Import data from a different Google Sheet.
First time: Sheets asks you to Allow Access. Click it. After that, data syncs automatically.
Use with QUERY for filtered imports:
Import a table or list from any web page.
Imports the first table from the Wikipedia page.
Import data from XML, HTML, or RSS feeds using XPath queries.
Returns all H1 headings from the page.
Get all links from a page:
Get page title:
Import a CSV or TSV file directly from a URL.
No parsing needed — Sheets automatically splits the data into columns.
Import functions recalculate periodically. For real-time data, use Google Apps Script.
Wrap in IFERROR to handle temporary failures:
Use cell references for URLs. Put the URL in a cell and reference it:
Now you can change the URL without editing the formula.
Combine with QUERY for large imports:
Permission errors. IMPORTRANGE requires access to the source sheet. Click Allow Access the first time, or ensure both sheets are in the same Google account.
HTML structure changes. IMPORTHTML and IMPORTXML break when the source website changes its layout. There is no fix except updating the formula.
Rate limits. Import functions can be slow if too many are used in one sheet. Google limits import frequency to prevent abuse.
Can I import from an Excel file? Not directly. Upload the Excel file to Google Drive first, then use IMPORTRANGE to reference it.
Why is my IMPORTHTML returning #N/A? The page structure may have changed, or the table index is wrong. Try different index numbers (1, 2, 3...) to find the right table.
How often do IMPORT functions refresh? Approximately every 1-2 hours. For immediate refresh, make a small edit to the sheet or use Google Apps Script.
Why This Matters
IMPORTRANGE — From Another Sheet
Syntax
=IMPORTRANGE(spreadsheet_url, range_string)Example
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/abc123", "Sheet1!A1:C100")=QUERY(IMPORTRANGE("url", "Sheet1!A1:C100"), "SELECT * WHERE Col2 > 500")IMPORTHTML — From a Web Table
Syntax
=IMPORTHTML(url, query, index)Example
=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_countries_by_GDP", "table", 1)| Argument | Description |
|---|---|
url | Full URL of the web page |
query | "table" for HTML tables, "list" for HTML lists |
index | Which table/list on the page (1 = first, 2 = second, etc.) |
IMPORTXML — From Structured Data
Syntax
=IMPORTXML(url, xpath_query)Example
=IMPORTXML("https://example.com", "//h1")=IMPORTXML("https://example.com", "//a/@href")=IMPORTXML("https://example.com", "//title")IMPORTDATA — From CSV/TSV
Syntax
=IMPORTDATA(url)Example
=IMPORTDATA("https://example.com/data.csv")Comparison
| Function | Best For | Update Frequency |
|---|---|---|
| IMPORTRANGE | Other Google Sheets | Every hour, or on change |
| IMPORTHTML | Web tables and lists | ~Every 2 hours |
| IMPORTXML | Structured web data | ~Every 2 hours |
| IMPORTDATA | CSV/TSV files | ~Every hour |
Pro Tips
=IFERROR(IMPORTRANGE("url", "Sheet1!A1:C100"), "Waiting for data...")=IMPORTRANGE(A1, "Sheet1!A1:C100")=QUERY(IMPORTRANGE("url", "Sheet1!A1:C10000"), "SELECT * WHERE Col1 IS NOT NULL")Common Mistakes
Related Functions
- QUERY Function — Filter and process your imported data
- FILTER Function — Filter imported data by conditions
- SPLIT Function — Clean up imported text data
FAQ
Topics
Topics in this article
Explore related topics and continue reading similar content.
Share this article
Discussion
Preparing the comments area...