1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Sub recup_html()
Dim PageWeb As Workbook, Wsh As Worksheet, C As Range, ChercheVal(1 To 4) As String, i As Byte, DerL As Integer
Application.ScreenUpdating = False
ChercheVal(1) = "Bel-20"
ChercheVal(2) = "Dow Jones"
ChercheVal(3) = "Nasdaq"
ChercheVal(4) = "EUR/USD"
Set Wsh = ThisWorkbook.Sheets(1)
Set PageWeb = Workbooks.Open("http://www.lecho.be/home")
Set C = PageWeb.Sheets(1).Cells.Find(what:="update", lookat:=xlPart)
If Not C Is Nothing Then
Wsh.Cells(Rows.Count, 1).End(xlUp).Offset(2, 0) = C.Text
End If
For i = 1 To 4
DerL = Wsh.Cells(Rows.Count, 1).End(xlUp).Row + 1
Set C = PageWeb.Sheets(1).Cells.Find(what:=ChercheVal(i), lookat:=xlWhole)
If Not C Is Nothing Then
Wsh.Cells(DerL, 1) = C.Text
Wsh.Cells(DerL, 2) = C.Offset(0, 1).Text
Wsh.Cells(DerL, 3) = C.Offset(0, 2).Text
End If
Next
PageWeb.Close False
Set PageWeb = Nothing
Set Wsh = Nothing
Set C = Nothing
Application.ScreenUpdating = True
End Sub |
Partager