We will explore a sample website from which we will fetch a table. In this case, we will visit microsoft.fandom.com. The following website has a table labeled Windows Servers containing two columns: Name and Release date. Using these two approaches, we will import this table from this website to Excel.
Method 1 – Utilizing Power Query
STEPS:
- In the active sheet, choose cell B4.
- Go to the Data tab, followed by From Web.
- The From Web window will pop up.
- In the URL Box, enter the URL of the Website you want to import tables.
- Press OK.
- The Navigator window will open. The left section contains all the tables, while the right section allows us to view each table.
- Choose Windows Servers. You will see an unnamed column. Import all columns except for this column.
- To do this, go to Transform Data.
- The Power Query window will open.
- Right-click on the top of the column.
- Select Remove.
- Go to Close & Load, followed by Close & Load To.
- The Import Data window opens.
- Check the Existing worksheet, then press OK.
- The following result should look like this.
Read More: How to Scrape Data from a Website into Excel
Method 2 – Using Excel VBA
STEPS:
- Choose the active sheet of the workbook as Sheet1.
- Go to Developer.
- Click Visual Basic.
- Select Insert, followed by Module.
- Enter the following code into the Module Box:
Sub SOFTEKOimporTablefromWeb()
Dim Data As QueryTable
Dim URL As String
URL = "https://microsoft.fandom.com/wiki/List_of_Microsoft_products"
Set Data = Sheet1.QueryTables.Add( _
Connection:="URL;" & URL, _
Destination:=Sheet1.Range("B4"))
With Data
.RefreshStyle = xlOverwriteCells
.WebFormatting = xlWebFormattingRTF
.WebSelectionType = xlSpecifiedTables
.WebTables = "2"
.Refresh
End With
End Sub
- Make sure to change the Range and the URL you want to visit.
- Press F5 or click the Run button to finish.
- The result should appear as follows:
Download the Practice Workbook
Download the workbook to practice.
Related Articles
- How to Automate Copy and Paste from Website to Excel
- How to Import Data from Secure Website to Excel
- How to Extract Data from Website to Excel Automatically
- How to Extract Data from Multiple Web Pages into Excel
- How to Import Data into Excel from Web
<< Go Back to Web Scraping in Excel | Importing Data in Excel | Learn Excel
Thanks for free code and it works for your website.
However it did not work for Concur Expense;
Error message as follows:
“This Web query returned no data. To change the query, click OK, click the arrow on the name box in the
formula bar, click the name of the eRernaI data range for the Web query, right-click the selection, and then
click Edit Query. ”
I suspect User login is a problem.
Would you help me modify code for above website?
Thanks and Kind Regards,
Hello GFIN SUNNY
Thanks for your nice words. Your appreciation means a lot to us. Thanks once again for sharing your problem.
Unfortunately, using VBA to automate web interactions with sites that require authentication is not easy when it requires login. You may need a more advanced approach to handle authentication, such as sending HTTP requests with the necessary credentials.
Regards
Lutfor Rahman Shimanto