Copying a table from a website into Excel by hand works once. When you need the same data every week, such as exchange rates, product prices, published statistics or a supplier’s stock list, it becomes a chore that is easy to get wrong. Web scraping in Excel with Power Query’s From Web connector solves this without a single line of VBA or Python. In this guide you will pull a web table into Excel, clean it, combine several pages into one table and set it to refresh on its own.
Everything here works in Excel for Microsoft 365, Excel 2021 and Excel 2019/2016 on Windows. Excel for Mac has Power Query, but the From Web connector is only available on Windows at the time of writing, so Mac users should build the query on a Windows PC or use Excel’s other import options.
What Power Query From Web can (and cannot) scrape
Power Query reads the HTML of a page and lists every table it can find. It works best on pages where the data sits in a real HTML table, which covers more sites than you might expect: statistics portals, Wikipedia lists, sports results, public price lists, government data pages and many internal company intranets.
It also handles JSON APIs well. If a site offers a URL that returns JSON, From Web will open it as structured records you can expand into columns.
It struggles with:
- Pages that load their data with JavaScript after the page opens. Power Query in Excel reads the page without running those scripts, so the table may simply not appear.
- Pages behind a login form, captcha or bot protection.
- Data shown as cards or lists rather than tables, such as many online shop product grids.
Before you start, check the site’s terms of use. Scraping public data for your own analysis is generally fine, but some sites forbid automated access or offer an official download or API that is the better route.
Step by step: pull a web table into Excel
- Open a blank workbook and go to Data, From Web. In some versions it is under Data, Get Data, From Other Sources, From Web.
- Paste the page 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 lists the tables it found, usually as Table 0, Table 1 and so on, plus a Document item for the whole page. Click each one to preview it until you find your data.
- Select the table and click Transform Data rather than Load. This opens the Power Query Editor, where you clean the data before it reaches your sheet.
- Clean it up: remove columns you do not need, use Home, Use First Row as Headers if needed, and set the correct data type for each column.
- Click Home, Close & Load. The data lands in a formatted Excel Table on a new sheet.
That is it. Next time you need fresh numbers, click inside the table and choose Data, Refresh All. Power Query downloads the page again and repeats every cleaning step.
Cleaning tips for web tables
Web tables are built for people, not spreadsheets, so they often need a few fixes:
- Footnote markers. Values like “1,234[3]” will not convert to numbers. Use Transform, Extract, Text Before Delimiter with “[” as the delimiter, then change the type to number.
- Currency symbols and units. Use Replace Values to remove “$”, “%” or “kg” before changing the data type.
- Thousand separators in a different locale. If a European site shows 1.234,56, use Change Type, Using Locale and pick the site’s locale.
- Repeated header rows. Long tables sometimes repeat headers every 50 rows. Filter them out with the column’s filter arrow.
Scrape several pages into one table
Many sites split results across pages with an address like ?page=2. Rather than creating a query per page, you can write a small function that downloads one page and then run it for each page number. Create a blank query (Data, Get Data, From Other Sources, Blank Query), open Advanced Editor and adapt this:
let
// Downloads one page and returns its first HTML table
GetPage = (PageNumber as number) as table =>
let
Source = Web.Page(
Web.Contents(
"https://www.example.com/products",
[Query = [page = Number.ToText(PageNumber)]]
)
),
PageTable = Source{0}[Data]
in
PageTable,
PageNumbers = {1..5}, // pages to fetch
AllPages = List.Transform(PageNumbers, each GetPage(_)),
Combined = Table.Combine(AllPages) // stack them
in
Combined
Replace the address with your site’s and adjust {1..5} to the number of pages. The Source{0}[Data] part picks the first table on the page. If your table was Table 2 in the Navigator, change it to Source{2}[Data]. Passing the page number through the Query option, rather than gluing it onto the address text, keeps the base address fixed, which makes the query more reliable to refresh.
Be polite with page counts. Fetching five or ten pages once a day is reasonable. Fetching hundreds of pages every few minutes can get your address blocked and puts load on someone else’s server.
Reading a JSON API instead
If the site offers an API that returns JSON, use the same From Web button with the API address. Power Query detects JSON and shows a List or Record. Click To Table, then the expand icon on the column header to turn the fields into columns. Behind the scenes it uses Json.Document(Web.Contents(...)), and the data is usually cleaner than anything scraped from HTML.
Keep the data fresh with automatic refresh
Right click the query in the Queries & Connections pane and choose Properties. Three settings are useful:
| Setting | What it does | Good for |
|---|---|---|
| Refresh every N minutes | Refreshes while the workbook is open | Rates or prices during the day |
| Refresh data when opening the file | Pulls fresh data every time the file opens | Weekly or monthly reports |
| Enable background refresh | Lets you keep working during a refresh | Slow sites or many pages |
To keep history, such as one price snapshot per day, Power Query alone is not enough because each refresh replaces the previous data. That is where a small VBA macro that copies the results to a History sheet, or a scheduled Python script, comes in.
Common mistakes with Excel web queries
- Picking the wrong table index. If the site adds a new table above yours, Table 0 may become Table 1. Check the Navigator again when results suddenly look wrong.
- Privacy level errors. Combining web data with a local file can trigger a Formula.Firewall message. Set privacy levels for each source in Data, Get Data, Data Source Settings.
- Changing types before cleaning. Converting “1,234[3]” to a number gives an error. Clean the text first, then set the data type.
- Expecting it to work on every site. If the Navigator shows no tables or only empty ones, the page probably loads its data with JavaScript. Look for an export button or API, or use a code-based scraper.
- Ignoring terms of use. Always check whether a site allows automated access.
Frequently asked questions
Is Power Query web scraping free?
Yes. Power Query is part of Excel, so there is nothing extra to buy or install. Power BI Desktop includes the same connector, also free.
Why does my web query show no tables?
The page most likely builds its content with JavaScript, or the data is not in an HTML table. Check for an API or download link, or use a browser-based scraper written in Python or VBA.
Can Power Query log in to a website?
It supports Basic and Windows authentication and API keys, but not normal website login forms. For pages behind a login form you usually need a browser automation tool such as Selenium.
Need data from a harder website?
For JavaScript-heavy sites, logins or scheduled scraping with history, I build custom scrapers in VBA and Python. You can see an example in my economic data web scraper project, read more about my web scraping service, or get an instant quote for your site.
