Excel has a built-in web browser that can be used to view web pages and import selected web data. This browser worked well for many years, but, recently, script errors began appearing on some pages. This makes it challenging to import data from some web pages, and frustrates users. The good news is that we can use a Get & Transform query as an alternative to opening Excel’s web browser.
Our goal is to import data from a web page. For example, we’d like to import some exchange rates from Google’s finance page. When we launch Excel’s web browser (Data > Get External Data > From Web), some pages show up just fine. This is illustrated below.
But, when we navigate to another page, we may get an intermittent script error. For example, if we try to navigate to Google’s Finance page shown below.
Often, you can refresh the page or close the browser and try again to get a clean page load, but, the error slows us down…and…we just don’t like being slowed down.
The good news is that we can retrieve web data using a Get & Transform query. This provides a clean alternative to Excel’s web browser. Let’s check it out.
Get & Transform Query
We’ll accomplish this with the following steps:
- Enter the web page URL
- Pick the data table
- Load to Excel
We’ll work through each step together.
Note: The steps below are presented with Excel for Windows 2016. If you are using a different version of Excel, please note that the features presented may not be available or you may need to download and install the Power Query Add-in.
Enter the web page URL
To retrieve web data using a Get & Transform query, you’ll need to know the web URL. You can commit it to memory if it’s short and simple, or, just browse to the page in your normal browser and copy the web address. Next, you’ll want to use the following command from the Get & Transform ribbon group:
- Data > New Query > From Other Sources > From Web
This displays the From Web dialog, where we can enter the desired URL, as shown below.
We click OK to open the Navigator dialog, where we can pick the desired data table.
Pick the data table
The Navigator dialog displays the importable web tables that exist at the URL. You can click through the tables and get a preview of the data. Since we want the exchange rate table, we click through the tables until we find the one we want, as shown below.
With the data table selected, it is time to move to the final step.
Load to Excel
We use the Load button to bring the data back into Excel. If we select Load, Excel will place the data into a blank worksheet. If we select Load To, Excel allows us to specify the destination. Either way, the data is loaded into Excel, as shown below.
Now, the best part is that we can easily update the data table from within Excel. Just right-click and refresh…and Excel retrieves the current data. And…no pesky script errors!
- Sample Excel file: WebData
- Excel web browser: http://www.excel-university.com/articles/cal-cpa/excel-on-the-web/
- Stock quotes: http://www.excel-university.com/articles/cal-cpa/market-share/