PDA

View Full Version : Help with Data copy from IE to Excel



Galleon
08-05-2014, 08:02 AM
Hi all,

I am looking for some assistance, I have some code that navigates to a URL specified by text in an Excel Cell, copies part of the text on the website via IE and pastes in a specified cell. However I require to drill down the text it copies as it copies too much at present when inputting the element id. Also I would like excel to find the next empty cell, as I need to go through about 400 pages and take data, so I cannot specify 400 cells. The website I am accessing is via UN & PW so providing you the link wont help, I can however if needed copy the element html code.

Below is my VBA code; I hope you can help.

Private Sub blahblah_Click()
Dim ie As Object
Dim WB As Workbook
Dim WS As Worksheet
Set WB = Workbooks("hopef.xlsm")
Set WS = WB.Sheets("Sheet1")
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
For Each URL In Range("A2")
.Navigate URL.Value
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
y = ie.Document.getelementbyid("scheme_assets").innerHTML
WS.Range("A1").Value = y
Application.Wait DateAdd("s", 1, Now)
p = ie.Document.getelementbyid("adviser_fund_wrapper").innerHTML
WS.Range("B1").Value = p
Next
With ie
.Visible = True
For Each URL In Range("A3")
.Navigate URL.Value
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
y = ie.Document.getelementbyid("scheme_assets").innerHTML
WS.Range("c1").Value = y
Application.Wait DateAdd("s", 1, Now)
p = ie.Document.getelementbyid("adviser_fund_wrapper").innerHTML
WS.Range("d1").Value = p
Next
End With

End With
End Sub