IMPORTHTML in Google Sheets: Import a Web Table or List
Use IMPORTHTML in Google Sheets with the correct table or list index, verify source headers and rows, and avoid fragile assumptions about page layout and refresh behavior.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =IMPORTHTML("https://www.w3schools.com/html/html_tables.asp","table",1) requests the first HTML table on that page. The inspected source contains a three-column example with a header row and six data rows.
Syntax and indexing
=IMPORTHTML(url, query, index)
The Google IMPORTHTML reference documents three required arguments:
| Argument | Meaning |
|---|---|
| url | Full page address, including its protocol |
| query | Either table or list, supplied as quoted text or a cell value |
| index | Which matching table or list to return, starting at 1 |
Table and list indexes are counted separately. The first table and first list can both have index 1 on the same page. The index is not a row number inside the selected table, a CSS selector or the ID of an HTML element.
Use "table" for a table and "list" for a list. Neither the page title nor a heading that looks like a table in the browser is itself a valid query value.
Worked example: import a small teaching table
Create tabs named Setup, Raw and Analysis. Put this URL in Setup!A1:
https://www.w3schools.com/html/html_tables.asp
In Raw!A1, enter:
=IMPORTHTML(Setup!A1,"table",1)
The publisher’s HTML page was retrieved independently on October 17, 2026. Its first actual table has 7 rows and 3 columns, including the header. Expected selected cells are:
| Cell | Source content |
|---|---|
| A1 | Company |
| B1 | Contact |
| C1 | Country |
| A2 | Alfreds Futterkiste |
| C2 | Germany |
For that snapshot, the expected result occupies A1:C7. Keep this rectangle clear. These values and dimensions were checked in the source HTML, not observed in a live Sheets import.
The source table’s header is part of the table itself. IMPORTHTML has no separate headers argument in its documented syntax; do not add a fourth argument merely because another import function has one.
Independent source check
The retrieved page contained two actual table elements, and the first had the HTML ID customers. That ID is useful when inspecting the source, but the IMPORTHTML formula still uses the ordinal index 1.
If the publisher inserts a new table before it, the same formula may select a different table. A successful import can therefore be wrong without producing a spreadsheet error. Compare the expected header labels and a known row before reusing downstream calculations.
The function operates on structures defined in the HTML source. A browser can display content assembled after scripts run; the existence of a visual grid alone does not establish that the fetched HTML contains a corresponding table element. Inspect the source when the expected structure cannot be found.
Advanced application: summarize the imported categories
On Analysis, count the Germany entries in the six source rows:
=COUNTIF(Raw!C2:C7,"Germany")
Expected result for the snapshot: 1. A comparison query is:
=COUNTIF(Raw!C2:C7,"Brazil")
Expected result: 0. These are counts in a teaching dataset, not statements about the distribution of real companies.
To check the data-row count without including the header:
=COUNTIF(Raw!A2:A7,"*")
Expected result: 6, because every company entry in those rows is text. This count is independent of the country filter. Including the header row would produce 7 instead.
Keep one import on Raw and reuse it in several analysis formulas. Repeating the external import for each category adds unnecessary requests and makes it harder to compare results from the same fetched table.
Lists and changing page layouts
To request a list, change the query argument to "list" and identify the desired list’s separate source index. Do not reuse table index 1 expecting it to refer to the same content in list form.
Navigation menus and other lists can precede the content you want. Likewise, decorative or unrelated tables can affect table indexes. Use a small source inspection whenever the page changes rather than repeatedly guessing larger indexes.
Merged cells, nested structures and complicated layout tables can make the imported rectangle less straightforward. Their exact native normalization was not established here; the worked example deliberately uses a simple rectangular table.
Refresh, errors and access
Google’s import guidance says IMPORTHTML checks for updates hourly while the spreadsheet is open. Reloading the document is not itself a refresh trigger. Formula replacement can trigger fetching, but repeated changes can contribute to traffic limits across the creator’s documents.
An editor may need to approve external-data access. If an administrator blocks the source, resolve that policy issue with the administrator. A browser’s ability to display a page does not prove that Sheets is authorized or able to fetch it.
Check the URL, query spelling, index and expected headers before suppressing an error. Volatile dependencies such as NOW and RAND are restricted; Google identifies TODAY as an exception. Exact native error tokens for every invalid index or unsupported structure were not established.
Availability and verification
IMPORTHTML is currently documented for rolling Google Sheets. Original introduction date and first or last numbered releases were not established. Similar web-import features elsewhere are not assumed to share this indexing contract.
NOT_TESTED_IN_GOOGLE_SHEETS. Google documentation and the actual source HTML were inspected on October 17, 2026. Table order, dimensions, selected text and category counts were independently parsed. No native import, permission grant or screenshot is claimed.