Bird
Raised Fist0
Google Sheetsspreadsheet~10 mins

IMPORTHTML for web tables in Google Sheets - Cell-by-Cell Formula Trace

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Sample Data

Sample table of countries and their capitals, similar to a web table that IMPORTHTML would fetch.

CellValue
A1Country
B1Capital
A2France
B2Paris
A3Germany
B3Berlin
A4Italy
B4Rome
Formula Trace
=IMPORTHTML("https://example.com/countries", "table", 1)
Step 1: IMPORTHTML("https://example.com/countries", "table", 1)
Step 2: Place the fetched table data into the sheet starting at the formula cell
Cell Reference Map
Sheet:
+----+---------+---------+
|    |    A    |    B    |
+----+---------+---------+
| 1  | Country | Capital |
| 2  | France  | Paris   |
| 3  | Germany | Berlin  |
| 4  | Italy   | Rome    |
+----+---------+---------+

Formula in cell A1: =IMPORTHTML("https://example.com/countries", "table", 1)

Arrows: Formula fetches entire table into A1:B4
The formula in A1 imports the first table from the given URL, filling cells A1 through B4 with the table data.
Result
Sheet after formula evaluation:
+----+---------+---------+
|    |    A    |    B    |
+----+---------+---------+
| 1  | Country | Capital |
| 2  | France  | Paris   |
| 3  | Germany | Berlin  |
| 4  | Italy   | Rome    |
+----+---------+---------+
The sheet shows the imported table with headers and data from the web page, exactly as fetched by IMPORTHTML.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the number 1 mean in the formula =IMPORTHTML("https://example.com/countries", "table", 1)?
AIt selects the first table on the webpage
BIt selects the first row of the table
CIt selects the first column of the table
DIt limits the import to one cell
Key Result
IMPORTHTML(url, "table", index) imports the entire table at position index from the webpage at url.

Practice

(1/5)
1. What does the IMPORTHTML function do in Google Sheets?
easy
A. It imports tables or lists from a web page into your spreadsheet.
B. It imports images from a web page into your spreadsheet.
C. It exports your spreadsheet data to a web page.
D. It creates charts based on web page data.

Solution

  1. Step 1: Understand IMPORTHTML purpose

    The IMPORTHTML function is designed to pull data from web pages, specifically tables or lists.
  2. Step 2: Identify correct data type imported

    It imports structured data like tables or lists, not images or charts.
  3. Final Answer:

    It imports tables or lists from a web page into your spreadsheet. -> Option A
  4. Quick Check:

    IMPORTHTML imports tables/lists [OK]
Hint: IMPORTHTML grabs tables or lists from URLs [OK]
Common Mistakes:
  • Thinking it imports images or charts
  • Confusing IMPORTHTML with export functions
  • Assuming it imports unstructured text
2. Which of the following is the correct syntax to import the first table from a webpage using IMPORTHTML?
easy
A. =IMPORTHTML("http://example.com", "list", 1)
B. =IMPORTHTML("http://example.com", "table")
C. =IMPORTHTML("http://example.com", "table", 1)
D. =IMPORTHTML("http://example.com", 1, "table")

Solution

  1. Step 1: Recall IMPORTHTML syntax

    The syntax is IMPORTHTML(url, query, index) where query is "table" or "list" and index is the number of the table or list.
  2. Step 2: Check each option

    =IMPORTHTML("http://example.com", "table", 1) matches the correct syntax with url, "table", and index 1. =IMPORTHTML("http://example.com", "list", 1) uses "list" instead of "table". =IMPORTHTML("http://example.com", "table") misses the index. =IMPORTHTML("http://example.com", 1, "table") has parameters in wrong order.
  3. Final Answer:

    =IMPORTHTML("http://example.com", "table", 1) -> Option C
  4. Quick Check:

    Correct syntax = IMPORTHTML(url, "table", index) [OK]
Hint: Syntax: IMPORTHTML(URL, "table" or "list", index) [OK]
Common Mistakes:
  • Omitting the index number
  • Swapping parameter order
  • Using wrong query type like "list" when table needed
3. Given the formula =IMPORTHTML("https://example.com/data", "table", 2), what will it do?
medium
A. Import the first list from the webpage at https://example.com/data
B. Import the second table from the webpage at https://example.com/data
C. Import the second list from the webpage at https://example.com/data
D. Import the first table from the webpage at https://example.com/data

Solution

  1. Step 1: Analyze the IMPORTHTML parameters

    The formula uses "table" as the query and 2 as the index, so it targets the second table on the page.
  2. Step 2: Match parameters to options

    Import the second table from the webpage at https://example.com/data correctly states it imports the second table. Options A and C mention lists, which is incorrect. Import the first table from the webpage at https://example.com/data mentions first table, which is wrong index.
  3. Final Answer:

    Import the second table from the webpage at https://example.com/data -> Option B
  4. Quick Check:

    "table" + 2 = second table imported [OK]
Hint: Index number picks which table or list to import [OK]
Common Mistakes:
  • Confusing 'table' with 'list'
  • Mixing up index numbers
  • Assuming it imports all tables at once
4. You wrote =IMPORTHTML("https://example.com", "table", "first") but get an error. What is the problem?
medium
A. The formula needs an extra parameter for headers.
B. The URL must end with .html to work.
C. The query parameter should be "list" instead of "table".
D. The index parameter must be a number, not text.

Solution

  1. Step 1: Check the index parameter type

    The third parameter must be a number indicating which table or list to import. "first" is text, causing an error.
  2. Step 2: Verify other parameters

    The URL can be any valid URL, no need to end with .html. The query "table" is valid. No extra parameter for headers is required.
  3. Final Answer:

    The index parameter must be a number, not text. -> Option D
  4. Quick Check:

    Index must be numeric [OK]
Hint: Index must be a number, not words [OK]
Common Mistakes:
  • Using text instead of number for index
  • Thinking URL must end with .html
  • Adding unnecessary parameters
5. You want to import the third table from a webpage but the page has only two tables. What will =IMPORTHTML("https://example.com", "table", 3) return?
hard
A. It will return an error indicating the table does not exist.
B. It will import the second table instead.
C. It will import an empty table with no data.
D. It will import the first table by default.

Solution

  1. Step 1: Understand IMPORTHTML behavior with invalid index

    If the index number is higher than the number of tables on the page, IMPORTHTML cannot find the requested table.
  2. Step 2: Result of requesting non-existent table

    Google Sheets returns an error because the requested table does not exist; it does not default to another table or return empty data.
  3. Final Answer:

    It will return an error indicating the table does not exist. -> Option A
  4. Quick Check:

    Invalid index causes error [OK]
Hint: Index must not exceed available tables [OK]
Common Mistakes:
  • Assuming it imports closest available table
  • Expecting empty data instead of error
  • Thinking it defaults to first table