IMPORTHTML function in Google Sheets: import a table or a list from a web page
IMPORTHTML imports a table or a list from a public web page into Google Sheets by its number on the page. This guide covers the syntax, how to find the right index, how to keep only some columns or rows with QUERY, how often the data refreshes, which pages the function cannot read, and the errors it returns.
IMPORTHTML imports a table or a list from a web page:
=IMPORTHTML("https://en.wikipedia.org/wiki/Currency", "table", 8, "en_US")
The formula loads the page, takes the eighth table in its HTML and writes it into the sheet, starting in the cell with the formula.

Reading to get this done?
IMPORTHTML syntax
=IMPORTHTML(url, query, index, [locale])
- url: the address of the page, with its protocol (https://). In quotation marks, or a reference to a cell that holds it.
- query:
"table"or"list", the kind of element to import. - index: the number of that table or list on the page, starting at 1. Tables and lists are numbered separately: a page can have a table 1 and a list 1.
- locale: optional. A language and region code, such as “en_US”, used to read the numbers and dates of the page. Without it, the locale of the spreadsheet applies.

With the arguments in cells, =IMPORTHTML(A2, B2, C2), one formula can be pointed at another page or table without editing it.
The first time: allow access
The first time IMPORTXML, IMPORTHTML, IMPORTDATA or IMPORTFEED is used in a file, Sheets shows a warning bar above the grid, “Some formulas are trying to send and receive data from external parties”, and the formula shows #REF! until Allow access is clicked in that bar. We saw exactly this in our test file.

According to Google’s help, the bar appears once per spreadsheet, only an editor of the file can click it, and on a phone it has to be done in a desktop browser.
Import a table
=IMPORTHTML("https://www.internetlivestats.com/internet-users/", "table", 1)

A “table” here means a table element in the HTML of the page. Blocks that only look like tables, built from other elements, are not found by the function.
The table you pull with IMPORTHTML shifts index or returns #N/A whenever the site redesigns, and your report goes blank.
Paste this into your AI assistant. It finds the index of the table you need on the page, writes the IMPORTHTML formula for it, and adds a check that shows when the import comes back empty.
The prompt
Read https://www.owox.com/ai-agent-setup.md and follow it to set up OWOX Data Marts for me, starting from /blog/articles/importhtml-function-google-sheets.md. The task: find the index of the table I need on the page I name, write the IMPORTHTML formula for it, and add a cell that warns me when the import comes back empty. Tag the links you give me with utm_campaign=ai-task and utm_term=m3. Use what you know about my context and goals
Import a list
=IMPORTHTML("https://en.wikipedia.org/wiki/Currency", "list", 8)

Lists are the bulleted and numbered lists of the page. Menus are lists too, which is why the first lists of a page are usually its navigation: on this page, list 1 returned “Main page” and the rest of the site menu in our test, list 2 the help links, and list 8 the contents of the article.
Find the index of a table or list
Find the index of a table or list
The index is the position of the element in the HTML source, which is not always the order you see on the page, and it moves when the page changes. The currencies table in the first example was table 6 when this guide was first written; two boxes added above it made it table 8, and the old formula kept working, returning one of those boxes. Three ways to find it:
- Try the numbers. Start with 1 and increase the index until the right table appears. For most pages this is the fastest way.
- Count in the developer tools. Right-click the table, choose Inspect, switch to the Console tab and enter
document.querySelectorAll("table").lengthto see how many tables the page has.document.querySelectorAll("table")[5]is the sixth of them, index 6 in the formula; hovering over the result highlights it on the page. The console counts the page after its scripts have run, while IMPORTHTML reads the HTML the server sends, so on script-heavy pages the two can differ; confirm by trying the number. - Put the index in a cell. With
=IMPORTHTML(A2, "table", C2), changing the number in C2 flips through the tables.
Keep only some columns or rows
Keep only some columns or rows
IMPORTHTML returns the whole table. Wrap it in QUERY to keep a part. The result is an array, so the columns are called Col1, Col2 and so on:
=QUERY(IMPORTHTML("https://www.bbc.com/sport/football/australian-a-league/table", "table", 1), "select Col1, Col2, Col3, Col4, Col5", 1)

The last argument, 1, says that the first row is a header. Other useful queries:
"select * where Col3 > 10"keeps the rows that meet a condition."select * order by Col2 desc limit 5"keeps the top five by a column."select Col1, Col4 where Col1 is not null"drops empty rows.
For a single value, INDEX takes one cell of the imported table: =INDEX(IMPORTHTML(A2, "table", 1), 3, 2) is the third row of the second column.
How often the data refreshes
IMPORTHTML re-reads the page by itself. Google’s help says that IMPORTDATA, IMPORTHTML and IMPORTXML check for updates every hour while the spreadsheet is open. Reloading the page does not trigger a refresh; deleting the formula and entering it again does.
What IMPORTHTML cannot do
- Pages behind a login. The request comes from Google’s servers, not from your browser, so only public pages can be read.
- Tables built by JavaScript. The function reads the HTML the server sends. A table that a script fills in after the page loads is not in that HTML, and the formula returns #N/A. Check with View page source: if the numbers are not in the source, they cannot be imported.
- Sites that block automated requests. Some sites refuse them or answer with a different page.
- A stable result on a changing site. When the site adds a table above yours, the index shifts and the formula starts returning another table, without an error.
- Anything but tables and lists. For other elements, such as headings, links or prices in the text, use IMPORTXML.
Check the terms of the site before collecting its content this way.
The import functions compared
| Function | Imports |
|---|---|
| IMPORTHTML | A table or a list from a web page, by its number |
| IMPORTXML | Any elements of a page or XML file, chosen by XPath |
| IMPORTDATA | A CSV or TSV file from a URL |
| IMPORTFEED | An RSS or Atom feed |
| IMPORTRANGE | A range from another Google spreadsheet |
Errors in IMPORTHTML
⚠️ Error: An error right after entering the formula, with a warning bar above the sheet.
✅ Solution: The file has not been allowed to fetch external data yet. Allow access in the warning bar.
⚠️ Error: #N/A with “Could not fetch url”.
✅ Solution: The address is wrong or lacks https://, the page needs a login, or the site refuses the request. Open the URL in a private browser window to see what an anonymous visitor gets.
⚠️ Error: #N/A with “Imported content is empty”.
✅ Solution: There is no table or list with this index in the HTML of the page (in our test, table 99 of a page with fourteen returned this message): the index is too high, the query should be “list” instead of “table”, or the table is built by JavaScript.
⚠️ Error: #REF! with “Array result was not expanded”.
✅ Solution: The cells the table needs are not empty. Clear the area below and to the right of the formula.
⚠️ Problem: The wrong table arrives.
✅ Solution: The index points to another table, or the site changed. Find the index again.
⚠️ Problem: Numbers arrive as text, or decimals are wrong.
✅ Solution: The page uses another number format than the spreadsheet. Set the locale in the fourth argument to match the page.
⚠️ Error: “Loading…” with the note “Loading data may take a while because of the large number of requests”.
✅ Solution: Too many import requests. Google counts them per creator of the file, across all the files that person has open, so the fix is fewer import formulas, not a faster connection. Replace finished results with values.
⚠️ Error: #ERROR! with “This function is not allowed to reference a cell with NOW(), RAND(), RANDARRAY(), or RANDBETWEEN()”.
✅ Solution: An import function cannot depend on a volatile function, directly or through another cell, which rules out the trick of adding NOW() to the address to force a refresh. TODAY is the one exception.
Related guides
- IMPORTXML: Page elements by XPath.
- IMPORTDATA: CSV and TSV files.
- IMPORTFEED: RSS and Atom feeds.
- IMPORTRANGE: Ranges from other spreadsheets.
- QUERY: Filter, sort and group what was imported.
- INDEX and MATCH: One value from the imported table.
A table on someone else’s page is a source you do not control
A table on someone else’s page is a source you do not control
IMPORTHTML is good for reference data that a site publishes as a table: rates, rankings, public statistics. As the base of a business report it is fragile. The index shifts when the page changes, the refresh runs hourly and only while the file is open, and your own spend, orders and revenue are not on a public page in the first place.
The OWOX Data Marts extension for Google Sheets covers that half. A data analyst publishes a data mart (a table or an SQL query in your data warehouse) and makes it available for reports. In Sheets you open the extension, pick the data mart, tick the columns you want and run it. The rows land in a tab, ready for your formulas.

What changes for the person who maintains the sheet:
- Refresh replaces re-export. Refresh current report in the extension menu re-runs the same pull, and a scheduled refresh keeps the tab current without anyone touching it.
- The source is written on the sheet. The header cell of an imported tab carries a note with the data mart it came from, the time of the import and a link to the report.
- No SQL and no warehouse access needed. The analyst decides which data marts and columns are available. You choose from that list.
The extension does not write or change the analyst’s SQL. IMPORTHTML keeps its place next to it, for the public reference table the report needs. The extension comes with the OWOX Cloud plans of OWOX Data Marts; spreadsheet reporting describes both ways data reaches a sheet.
The table you pull with IMPORTHTML shifts index or returns #N/A whenever the site redesigns, and your report goes blank.
Paste this into your AI assistant. It finds the index of the table you need on the page, writes the IMPORTHTML formula for it, and adds a check that shows when the import comes back empty.
The prompt
Read https://www.owox.com/ai-agent-setup.md and follow it to set up OWOX Data Marts for me, starting from /blog/articles/importhtml-function-google-sheets.md. The task: find the index of the table I need on the page I name, write the IMPORTHTML formula for it, and add a cell that warns me when the import comes back empty. Tag the links you give me with utm_campaign=ai-task and utm_term=m3. Use what you know about my context and goals
Prefer to start on your own? Get started free
Frequently Asked Questions
Can ImportHTML pull data from multiple tables on the same page?
Yes. Each table or list has its own index, so you can import them separately by changing the index number in the formula (e.g., 1, 2, 3, etc.).
Why is my ImportHTML formula returning blank cells or #N/A?
The usual causes are a wrong index, "table" where the element is a list (or the reverse), a table that JavaScript builds after the page loads, which the function cannot see, or a site that refuses automated requests. Check the page source: if the data is not in it, it cannot be imported.
How often does ImportHTML refresh data in Google Sheets?
Google's help says IMPORTHTML checks for updates every hour while the spreadsheet is open. Reloading the page does not trigger a refresh; deleting the formula and entering it again does.
What is the use of ImportHTML?
ImportHTML in Google Sheets is used for importing data from tables and lists found on HTML web pages. It's particularly useful for gathering structured data like financial tables or rankings without manual data entry.
