Extracting data (data collection and update) automatically from a web page to your Excel worksheet might be important for some jobs. Excel gives you the opportunity to collect data from a web page. This is one of the most used Excel features for those who use Excel for their data analysis job. If you are working for a financial analyst company, you might need to get or import daily stock prices from a website to your Excel workbook for analysis. In this article, I will show you how to extract data from a website to Excel automatically in easy steps.
We will be using Excel’s From Web command in the Data ribbon to collect data from the web. For example, I want to collect data from this page. It is the webpage of the U.S Energy Information Administration showing information on Petroleum prices.
Now, let us follow the below 4 steps to extract this data into Excel.
Step 1: Using Excel Power Query Tool to Insert Website Address
In the beginning, we will provide the website information in Excel.
- First, go to the Data tab and select From Web in the Get & Transform Data group.
- Then, insert the web URL in the From Web dialogue box.
- After that, press OK.
At this stage, we will proceed to the main part of extracting data. Let’s see how it works.
- First, you will see the Navigator window.
- Here, select the table from the Display Options.
- Along with it, you will see the preview in the Table View tab.
- Lastly, press on Load.
- That’s it, you have successfully extracted data from the website automatically.
Step 3: Applying Excel Refresh All Command for Data Update
So now, as we have our data, we will need confirmation that it is linked to the website. Because we want regular updates in our Excel file whenever there is an update on the website. So here is the solution.
- Simply go to the Data tab.
- Then click on Refresh All every time you want an update.
Step 4: Refreshing Data Automatically Within Fixed Time Limit
Data update is more flexible with the Connection Properties tool. Follow the process below:
- First, go to the Data tab and select Refresh All.
- Here, choose Connection Properties from the drop-down menu.
- Following, you will see the Query Properties dialogue box.
- Here, you can adjust the time to decide when you want an update from the website in the Refresh Control section.
- After that, click on OK.
How to Edit Extracted Data Table in Excel
So now, as we have our final extracted data, you can see that there are some blank cells that confuse the readers. Here is a quick editing solution for this extracted data table.
- In the beginning, double-click on the table showing in the Queries & Connections panel.
- Then, in the new window, select Down from the Transform tab.
- As a result, it will create an option in the Applied Steps.
- Here, select the Changed Type step.
- Then, select Replace Values in the Transform group from the Home tab.
- After this, agree to Insert in the Insert Step dialogue box.
- Next, insert the Replace With value as null and keep the Value To Find box blank.
- Afterward, press OK.
- Now, select Filled Down as the Applied Steps.
- Finally, you will see the whole table without any blank cells.
- Lastly, change the table name from the Query Settings.
- Then, press Close & Load.
- That’s it. Here is the final output.
Things to Remember
The web page must have data in collectible formats like Table or Pre-data format. Otherwise, it would be another battle to convert it to a readable or Excel-table format. You see, the Text to columns feature isn’t always your best friend.
So, this was a complete guideline for you on how to extract data from a website to Excel automatically with easy steps. Let us know your insightful suggestions in the comment box.