How to Import Data From a Website Into Excel
By ExcelReady TeamUpdated 6 min read
The short answer
To import data from a website into Excel on Windows, go to Data > From Web, paste the page address and click OK. In the Navigator, pick the table and click Load, or Transform Data to clean it first. You can refresh it later. If From Web can't see the data, paste it and clean it with TRIM and VALUE.
Key takeaways
- Data > From Web (Power Query) imports HTML tables from a web page into an Excel table you can refresh.
- Click Transform Data instead of Load to remove columns, fix types and filter rows before the data lands.
- Refresh with Data > Refresh All (Ctrl+Alt+F5 on Windows) or set the query to refresh on a schedule.
- Pasted web numbers are often text with extra spaces. VALUE(TRIM(cell)) turns them back into numbers.
- From Web reads tables in the page's HTML. Data drawn later by scripts or behind a login may not appear.
On this page+
To import data from a website into Excel, use Data > From Web: paste the page address, pick the table and load it. Excel keeps a link to the page, so you can refresh the data later instead of copying it again. This guide is for anyone who tracks prices, rates, schedules or published statistics from the web, and it also covers what to do when From Web can't reach the data.
The quick answer: Data > From Web#
From Web is part of Power Query, Excel's tool for getting and cleaning data (on the ribbon it appears as Get & Transform Data). It reads the tables in a web page and loads the one you choose into your workbook.
| Excel version | Where to find it |
|---|---|
| Microsoft 365, Excel 2024, 2021, 2019 (Windows) | Data > From Web in the Get & Transform Data group |
| Excel 2016 (Windows) | Data > New Query > From Other Sources > From Web |
| Excel 2010 and 2013 (Windows) | The separate Power Query add-in |
| Excel for Mac and Excel for the web | Fewer Power Query sources; From Web may not be listed |
If you're new to Power Query, Power Query for beginners explains the editor and its steps.
How to import a table from a website, step by step#
Here is the full process on Windows:
- Copy the address of the page from your browser, for example
https://example.com/prices. - In Excel, go to Data > From Web.
- Paste the address into the URL box and click OK.
- If Excel asks how to connect, choose Anonymous for a public page and click Connect.
- The Navigator window lists the tables it found, named Table 1, Table 2 and so on. Click each one to preview it. The Web View tab shows the page itself, which helps you spot the right table.
- Tick the table you want and click Load.
Excel adds a new sheet with the data as a formatted Excel table, and the query appears in the Queries & Connections pane. You can now sort it, chart it or point formulas at it. To show only some rows, use the filter buttons on the header row; the filter lesson covers them, including totals with SUBTOTAL.
Check the site's terms of use before you import from it regularly, and don't set a very short refresh interval on someone else's server.
Transform the data before you load it#
Click Transform Data instead of Load to clean the table in the Power Query Editor first. The common fixes for web tables are:
- Remove columns you don't need: select them and press Delete.
- Remove header or footer rows: Home > Remove Rows > Remove Top Rows.
- Fix data types: click the icon on a column header and pick Whole Number, Decimal Number or Date. Web tables often arrive as text.
- Trim and clean text: Transform > Format > Trim removes spaces at the ends.
Click Close & Load when you're done. Power Query records each step and repeats it on every refresh, so you only clean once. For when to use Power Query and when formulas are enough, see Power Query vs formulas.
Refresh the data automatically#
A web query is a live connection, so you can update it at any time:
- Refresh everything: Data > Refresh All, or Ctrl+Alt+F5 on Windows.
- Refresh one table: right-click inside it and choose Refresh.
- Refresh on a schedule: in Queries & Connections, right-click the query, choose Properties, and tick Refresh every with a number of minutes, or Refresh data when opening the file.
Formulas that point at the loaded table update with it. If the website changes its layout, the query may break; open it with Edit and adjust the step that fails.
When From Web can't see the data#
From Web reads the tables in the page's HTML. It struggles in three situations:
- Data drawn by scripts. Many modern pages load their tables after the page opens. Navigator may show no tables or only empty ones.
- Pages behind a login. Excel can't use the session from your browser.
- Data that isn't a table, such as cards or lists laid out with styling.
Try these alternatives, in order:
- Look for a download link. Many sites offer CSV or Excel downloads, which are cleaner than any web table. See how to import a CSV file into Excel.
- Use the site's data feed. If the site offers an API that returns JSON, paste that address into From Web. Power Query turns the JSON into a table you can expand.
- Copy and paste. Select the table in your browser, copy it, and paste it into Excel. Right-click and choose Match Destination Formatting to drop the web styles.
Clean pasted web data with TRIM and VALUE#
Pasted web data often looks fine but doesn't calculate. Numbers arrive as text, usually with extra spaces, so SUM returns 0. Here are four prices pasted from a page (the quotes show where the extra spaces are):
| A | B | |
|---|---|---|
| 1 | Product | Price (pasted) |
| 2 | Notebook | " 12.50 " |
| 3 | Pen set | "8.75 " |
| 4 | Desk lamp | " 21.00" |
| 5 | Stapler | "4.25" |
Fix one cell with TRIM and VALUE:
=VALUE(TRIM(B2))TRIM removes the spaces at the ends and turns double spaces inside into single ones, and VALUE turns the text "12.50" into the number 12.5. To total the whole column in one step:
=SUMPRODUCT(VALUE(TRIM(B2:B5)))The result is 46.5. The TRIM function guide and the VALUE function guide cover both in detail.
Web pages also use the non-breaking space, character 160, which TRIM does not remove. If VALUE still returns #VALUE!, replace it first:
=VALUE(TRIM(SUBSTITUTE(B2,CHAR(160)," ")))For more causes and fixes, read why numbers are stored as text and how to clean messy data in Excel.
Practise it#
Getting the data in is half the job; cleaning it is the part employers test. Practise cleaning messy text in a live spreadsheet: you'll use TRIM, PROPER and SUBSTITUTE, and each formula is checked instantly. Then practise filtering a table, or total the pasted prices in the exercise on this page.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
These prices were pasted from a web page as text with extra spaces, so =SUM(B2:B5) returns 0. Click D2 and total them with =SUMPRODUCT(VALUE(TRIM(B2:B5))).
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Price (pasted) | ||||
| 2 | Total | ||||
| 3 | 8.75 | ||||
| 4 | 21.00 | ||||
| 5 | 4.25 | ||||
| 6 | |||||
| 7 | |||||
| 8 |
Tip: TRIM removes the spaces, VALUE turns each text price into a number, and SUMPRODUCT adds them up. The answer is 46.5.
Practise this in a lesson
Frequently asked questions
How do I pull data from a website into Excel automatically?
Use Data > From Web to create a query, then open the query's properties and turn on Refresh every so many minutes or Refresh data when opening the file. Excel then reloads the table without any copying.
Why does Excel From Web not show the table I see in my browser?
Many pages build their tables with scripts after the page loads, or show data only after you sign in. From Web reads the page's HTML, so that data may not be there. Look for a download or CSV link instead.
Is From Web available in Excel for Mac?
Power Query on Mac and in Excel for the web supports fewer data sources than Excel for Windows. If From Web is not on your Data tab, copy and paste the table or download a CSV file.
Why are numbers copied from a website not adding up?
They were pasted as text, often with extra spaces or non-breaking spaces. Use =VALUE(TRIM(A2)) to convert them, and SUBSTITUTE(A2,CHAR(160),"") to remove non-breaking spaces first.