khaledocom
New Member
- Joined
- Jan 1, 2010
- Messages
- 29
Dear friends,
I would like to import the following:
Table 0 from: https://www.global-rates.com/interest-rates/libor/american-dollar/american-dollar.aspx
Another table named: additional information per maturity from: https://www.global-rates.com/interest-rates/libor/american-dollar/2019.aspx
I tried the below code but it's importing entire page:
Dim HTMLDoc As New HTMLDocument
Dim objTable As Object
Dim lRow As Long
Dim lngTable As Long
Dim lngRow As Long
Dim lngCol As Long
Dim ActRw As Long
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.navigate "https://www.global-rates.com/interest-rates/libor/american-dollar/2019.aspx"
Do Until objIE.readyState = 4 And Not objIE.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:03")) 'wait for java script to load
HTMLDoc.body.innerHTML = objIE.document.body.innerHTML
With HTMLDoc.body
Set objTable = .getElementsByTagName("table")
For lngTable = 0 To objTable.Length - 1
For lngRow = 0 To objTable(lngTable).Rows.Length - 1
For lngCol = 0 To objTable(lngTable).Rows(lngRow).Cells.Length - 1
ThisWorkbook.Sheets("Sheet1").Cells(ActRw + lngRow + 1, lngCol + 1) = objTable(lngTable).Rows(lngRow).Cells(lngCol).innerText
Next lngCol
Next lngRow
ActRw = ActRw + objTable(lngTable).Rows.Length + 1
Next lngTable
End With
Rows("2:3086").Delete
Range("A1") = "US Dollar LIBOR interest rates 2019, all maturities"
Rows("37:200").Delete
Rows("19:23").Delete
coluns("A:F").AutoFit
objIE.Quit
Thankful for your kind support.
I would like to import the following:
Table 0 from: https://www.global-rates.com/interest-rates/libor/american-dollar/american-dollar.aspx
Another table named: additional information per maturity from: https://www.global-rates.com/interest-rates/libor/american-dollar/2019.aspx
I tried the below code but it's importing entire page:
Dim HTMLDoc As New HTMLDocument
Dim objTable As Object
Dim lRow As Long
Dim lngTable As Long
Dim lngRow As Long
Dim lngCol As Long
Dim ActRw As Long
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.navigate "https://www.global-rates.com/interest-rates/libor/american-dollar/2019.aspx"
Do Until objIE.readyState = 4 And Not objIE.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:03")) 'wait for java script to load
HTMLDoc.body.innerHTML = objIE.document.body.innerHTML
With HTMLDoc.body
Set objTable = .getElementsByTagName("table")
For lngTable = 0 To objTable.Length - 1
For lngRow = 0 To objTable(lngTable).Rows.Length - 1
For lngCol = 0 To objTable(lngTable).Rows(lngRow).Cells.Length - 1
ThisWorkbook.Sheets("Sheet1").Cells(ActRw + lngRow + 1, lngCol + 1) = objTable(lngTable).Rows(lngRow).Cells(lngCol).innerText
Next lngCol
Next lngRow
ActRw = ActRw + objTable(lngTable).Rows.Length + 1
Next lngTable
End With
Rows("2:3086").Delete
Range("A1") = "US Dollar LIBOR interest rates 2019, all maturities"
Rows("37:200").Delete
Rows("19:23").Delete
coluns("A:F").AutoFit
objIE.Quit
Thankful for your kind support.