0
I would like to import one cell from a web table to excel.
This is the daily price of copper.
I find for the code and found one part of this.
Please help me to complete the code which imports only the cell in the second row, and second column.
Thx!
I would like to import one cell from a web table to excel.
This is the daily price of copper.
I find for the code and found one part of this.
Please help me to complete the code which imports only the cell in the second row, and second column.
Thx!
VBA Code:
Dim htm As Object
Dim Tr As Object
Dim Td As Object
Dim Tab1 As Object
Dim URL As String
Dim Colstart As Long
Dim html As Variant
Dim i As Long
Dim j As Long
Dim n As Long
Dim szoveg1 As String
szoveg1 = "https://www.kabelring.hu/arfolyamok"
Application.ScreenUpdating = False
URL = szoveg1
Set html = CreateObject("htmlfile") 'Create HTMLFile Object
With CreateObject("msxml2.xmlhttp") 'Get the WebPage Content
.Open "GET", URL, False
.send
html.body.innerHTML = .responseText
End With
Colstart = 1 'vízszintes eltolás
j = 1 'függőleges eltolás
i = Colstart
n = 0
'Loop Through website tables
For Each Tab1 In html.getElementsByTagName("table")
With html.getElementsByTagName("table")(n)
For Each Tr In .Rows
For Each Td In Tr.Cells
Munka1.Cells(j, i) = Td.innerText
i = i + 1 'táblázaton belüli függőleges beolvasás
Next Td
i = Colstart
j = j + 1 'adatok közötti függőleges cellatávolság
Next Tr
End With
n = n + 1
i = Colstart
j = j + 1
Next Tab1
Application.ScreenUpdating = True
End Sub