Data scraping - VBA

Buggington

New Member
Joined
Mar 28, 2014
Messages
8
Hello :)

I'm a total VBA newbie, but need to create a data scraping tool. I've managed to find something on YouTube that showed me how to do the majority of what I want, but it doesn't seem to be working.

This is what I have so far:
Code:
Sub ie_open()
    
    Dim iRet As Integer
    Dim strPrompt As String
    Dim strTitle As String
 
    ' Promt
    strPrompt = "Open site to login and find product?"
 
    ' Dialog's Title
    strTitle = "EPOS"
 
    'Display MessageBox
    iRet = MsgBox(strPrompt, vbYesNo, strTitle)
 
    ' Check pressed button
        If iRet = vbNo Then
        MsgBox "Cancelled."
    Else
        Dim ie As Object
        Set ie = CreateObject("InternetExplorer.Application")
        ie.Navigate "[URL="http://www.google.com"]www.google.com[/URL]"
        ie.Visible = True
        
        MsgBox "Click OK when page is ready"
    End If
    
    Do While ie.Busy: DoEvents: Loop
    
    Set TDelements = ie.Document.getElementsbytagname("GridLabel-")
    r = 0
    c = 0
    
    For Each TDelement In TDelements
    Tabelle1.Range("A1").Offset(r, c).Value = TDelement.innertext
    r = r + 1
        Next
    
    Set ie = Nothing
    
    End Sub

When I step through the code, everything runs absolutely fine until I get to the "Tabelle1.Range" line, where it seems to skip straight to "Set ie = Nothing" rather than get the data.

Any ideas what's happening here? It's worth noting that I've changed the web URL as it's company data.

Thanks :)
 
Hi - thanks for the responses. Unfortunately I've had a few days out of the office and so have to catch up on things. Hopefully I'll get time to deal with this tomorrow - I haven't forgotten about this!
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top