Results 1 to 9 of 9

VBA scrape data from website HTML

Threaded View

  1. #1
    Registered User
    Join Date
    02-11-2017
    Location
    PT
    MS-Off Ver
    2015
    Posts
    6

    VBA scrape data from website HTML

    Hi,

    I made a VBA code that scrapes the morningstar dates of some mutual fund quotes, and places them in a column, right to the fund id.
    Nevertheless, I have been trying to code the exact same operation, but instead of placing fund ID on a column, place it on a line, and expect excel to scrape the dates on the line below, just like indicated:

    screenshot.PNG


    Could you be so kind as to show me how can I fix my code to do so?

    .xls file:

    https://we.tl/BMFb7jDGAc


    VBA code:

    Sub DatesMSTAR()
    '
    Dim ie As Object
    Set Rng = Range("A3:A26")
    Set Row = Range(Rng.Offset(1, 0), Rng.Offset(1, 0).End(xlDown))
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
    
    For Each Row In Rng
    .navigate "http://www.morningstar.pt/pt/funds/snapshot/snapshot.aspx?id=" & Range("A" & Row.Row).Value & ""
    Do
    DoEvents
    Loop Until ie.readyState = READYSTATE_COMPLETE
    Dim doc As HTMLDocument
    Set doc = ie.document
    While ie.readyState <> 4
    Wend
    
    Application.Wait (Now + TimeValue("0:00:01"))
    
    On Error Resume Next
    Range("B" & Row.Row).Value = doc.getElementsByClassName("heading")(2).innerText
    Next Row
    ie.Quit
    
    End With
    End Sub

    Thanks so much!
    Last edited by Strutland; 02-11-2017 at 11:36 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to Scrape information from a website and put in specific column of existing worksheet.
    By Glove83 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-22-2015, 11:44 AM
  2. Scrape website using VBA
    By cfcMalky in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-26-2014, 08:59 PM
  3. Logon daily to website, Scrape data, and paste into Excel 2003 Using VBA
    By Gloopie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2014, 09:25 AM
  4. 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
  5. VBA Macro to Scrape Website - Post to Javascript
    By shahzeb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2014, 05:53 PM
  6. [SOLVED] Pull Specific Data from Website (Screen Scrape)
    By CHRISEWRIGHT20 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-11-2012, 11:03 AM
  7. VBA to scrape data from website
    By jdub22cb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2012, 04:00 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