Import Data from a Website into Excel


import data from multiple pages of a website into a single excel sheet

Post Edited
Title: Title was not descriptive.


Is your query similar to this one?
Chhabi Acharya (rep: 109) Sep 13, '18 at 11:29 am
Hi Chhabi Acharya, thanks for your response,  infact I am looking for

Eg :

By changing numbers , data should insert into excel.  

MrBobs Sep 13, '18 at 12:28 pm
Add to Discussion



Your intention isn't related to Excel in the sense that Excel is only the final recipient of the data which are to be obtained by scraping websites. I suggest you ask your question on a forum where they discuss scraping techniques.


This is probably the kind of thing that you need:

Sub ExcelWebsiteLogin()
' macro to login to a website.

Dim ie      As Object
Dim frm     As Variant
Dim element As Variant

'Requires Microsoft Internet Controls to be activated. Tools > References > Microsoft Internet Controls
Set ie = New InternetExplorerMedium

'website page where the login form is located
ie.navigate ""

While ie.readyState <> 4: DoEvents: Wend

'ID of the login form
Set frm = ie.document.getElementById("login_form")

'Name of the form, if there is no ID for it.
If frm Is Nothing Then Set frm = ie.document.getElementsByName("login_form").Item(0)

If frm Is Nothing Then
   'Form not found.

   'Error message if the form was not found
   MsgBox "Login form not found."

   'Kill the internet explorer instance
   Set ie = Nothing

   'Form found, proceed to fill it out and then submit it.

   'Display the browser
   ie.Visible = True

   'Go through elements in the browser
   For Each element In frm.elements

      On Error Resume Next

      'Input values into the form fields in the browser
      Select Case element.Name
         Case "email": element.Value = ""
         Case "password": element.Value = "password"
      End Select


   'submit the form

End If

End Sub

This is one of our macros and it is explained here: Web Query Login Macro

Though the macro is for logging into a website, the techniques and concepts that are illustrated in it are directly applicable to what you are doing and should give you a major head-start on your project.


Answer the Question

You must create an account to use the forum. Create an Account or Login