Home How to repeat VBA macro with cell references changing
Reply: 0

How to repeat VBA macro with cell references changing

user1011 Published in July 21, 2018, 1:42 pm

I have written the following code which scrapes webpages based on a URL (in cell B2) and then outputs a number scraped from the page in C2.

Sub Scrape()
    Dim ObjIE As Object
    Set ObjIE = CreateObject("InternetExplorer.Application")
    ObjIE.Navigate Sheets("facebook").Range("B2").Value

    Application.StatusBar = "Loading, Please wait..."

    Do While ObjIE.Busy
        Application.Wait DateAdd("s", 1, Now)

    Application.StatusBar = "Searching for value. Please wait..."

    Dim dd As String
    dd = ObjIE.Document.getElementsByClassName("_3xom")(0).innerText

    Sheets("Facebook").Range("C2") = dd

    Dim cell As Range
End Sub

I have more URLs in column B. I need to find some code which will repeat the macro but change the two cell references to "B3" and "C3" respectively, and then 4, 5, 6 and so forth. I've tried all kind of loops but cant work out what might make this work!

Any help would be super appreciated.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.317141 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO