I want to get all the data from an internet table and put it in excel. I tried with the code below, but the following error appears in the 'For Each' line:
"Run-time error '438': Object does not accept this property or method "
Sub CCEE_precoMedio()
Dim ie As Object
Dim doc As Object, elem As Object, trow As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "https://www.ccee.org.br/portal/faces/pages_publico/o-que-fazemos/como_ccee_atua/precos/precos_medios?_adf.ctrl-state=trut1o6ix_5&_afrLoop="
ie.Visible = True
Do Until (ie.readyState = 4 And Not ie.Busy)
DoEvents
Loop
Set doc = ie.document.getElementsByClassName("displaytag-Table_soma")
r = 1
For Each elem In doc.getElementsByTagName("tr")
For Each trow In elem.getElementsByTagName("td")
y = y + 1: Cells(r + 1, y + 1) = trow.innerText
Next trow
y = 0
r = r + 1
Next elem
End Sub
I believe that the error is in how I refer the item. How do I fix this?