0

I am currently trying to scrap data from a website using VBA. I am following this tutorial and hence my code is the following one:

Sub Foo()

    Dim appIE As Object
    Set appIE = CreateObject("internetexplorer.application")

    With appIE
        .Navigate "https://www.ishares.com/it/investitore-privato/it/prodotti/251843/ishares-euro-high-yield-corporate-bond-ucits-etf"
        .Visible = True
    End With

    Do While appIE.Busy
        DoEvents
    Loop

    Set allRowOfData = appIE.document.getElementsByClassName("visible-data totalNetAssets")
    Dim myValue As String
    myValue = allRowOfData.Cells(1).innerHTML
    MsgBox myValue

End Sub

Unfortunately there are some differences between data I want to scrap and those ones used in the example: this line

myValue = allRowOfData.Cells(1).innerHTML

is wrong according to VBA debug.

Anyone could provide me with some explanations about why that doesn't work and how am I supposed to pick the right method to scrap HTML pages?

Community
  • 1
  • 1
Lisa Ann
  • 3,345
  • 6
  • 31
  • 42

1 Answers1

2

Try the below change which will solve your issue. In brief, you will need to treat the allRowofData as a collection.

myValue = allRowOfData(0).Cells(1).innerHTML
Lemon Kazi
  • 3,308
  • 2
  • 37
  • 67