+ Reply to Thread
Results 1 to 2 of 2

Scrape Data Using VBA From IE to Excel - Help with code

  1. #1
    Registered User
    Join Date
    08-05-2014
    Location
    scotland
    MS-Off Ver
    2010
    Posts
    1

    Scrape Data Using VBA From IE to Excel - Help with code

    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

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Scrape Data Using VBA From IE to Excel - Help with code

    If you can supply a copy of the HTML source code and what it is you are trying to find within the code, i might be able to help.
    Although first of all you need to put your code within tags.

    Select edit, highlight the code within your thread and then click the # symbol on the tool bar.
    then resave it. otherwise you will possibly get an infraction or telling off!
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Scrape, pull or get data from a Website into Excel Please help me out
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2014, 01:42 PM
  2. Screen Scrape Code
    By bpeyton in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2013, 02:57 PM
  3. Having trouble with Excel web query for data scrape
    By stevenab87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2012, 10:18 PM
  4. VBA to scrape data from website
    By jdub22cb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2012, 04:00 PM
  5. Code to scrape system generated outlook email doesn't get all the data
    By bobaftt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2010, 01:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1