+ Reply to Thread
Results 1 to 2 of 2

Need assistance with macro that scrapes web data - Need to place across columns.

Hybrid View

  1. #1
    Registered User
    Join Date
    09-08-2008
    Location
    Elk Grove, California
    Posts
    21

    Need assistance with macro that scrapes web data - Need to place across columns.

    I have the following code which is getting the data that I want. It presently stacks the scraped data in column("A"). I am looking for assistance in changing it, so it goes across the columns. Starting columns would be "A", Last Column would be "J", then advance to next row.

    Sub Extract_TD_text()
         
        Dim URL As String
        Dim IE As InternetExplorer
        Dim HTMLdoc As HTMLDocument
        Dim TDelements As IHTMLElementCollection
        Dim TDelement As HTMLTableCell
        Dim r As Long
         
         'Saved from www vbaexpress com/forum/forumdisplay.php?f=17
        URL = "http://www.vegasinsider.com/mlb/matchups/matchups.cfm/date/04-14-17"
         
        Set IE = New InternetExplorer
         
        With IE
            .navigate URL
            .Visible = True
             
             'Wait for page to load
            While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
                 
                Set HTMLdoc = .document
            End With
             
            Set TDelements = HTMLdoc.getElementsByTagName("TD")
             
            Sheet2.Cells.ClearContents
             
            r = 0
            For Each TDelement In TDelements
                 'Look for required TD elements - this check is specific to VBA Express forum - modify as required
                If TDelement.className = "viBodyBorderNorm" Then
                    Sheet2.Range("A1").Offset(r, 0).Value = TDelement.innerText
                    r = r + 1
                End If
            Next
             
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need assistance with macro that scrapes web data - Need to place across columns.

    I used a different code. Try it.
    Attached Files Attached Files

+ 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. Replies: 3
    Last Post: 06-29-2016, 01:38 PM
  2. Replies: 12
    Last Post: 03-14-2016, 08:42 AM
  3. Replies: 5
    Last Post: 10-01-2015, 08:04 AM
  4. [SOLVED] Macro to sort and place data in adjacent columns
    By T15K in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-01-2013, 06:14 AM
  5. Need VBA Macro Assistance - Data in three columns, transpose to row format
    By matthewjberry in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-05-2013, 11:50 AM
  6. [SOLVED] Macro assistance to identify dates in one range and place text in a cell in worksheets
    By lilsnoop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2013, 12:29 PM
  7. How do I create a macro that will compare columns and place data
    By CompuCat in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-20-2006, 02:25 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