Merci Bart,
alors oui j'étais bien à coté de la plaque ... :-)
donc le VBA : Feuil1(COTATIONS)
le tableau : tableau_cotations
le code utilisé :
Function GetHtmlcode(UrL As String)
On Error Resume Next
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", UrL, False
.Send
If .Status = 200 Then
GetHtmlcode = .responsetext
End If
End With
End Function
Sub m_GO()
Dim tbl, UrL$, Codehtml, oTable, TableHtmL, TRS, LiG&, C&, E, A&, b, sCurr, sp
tbl = Feuil1.Range("tableau_cotations")
For LiG = 1 To UBound(tbl)
UrL = tbl(LiG, 1)
Application.StatusBar = "Téléchargement des données de : " & tbl(LiG, 1)
Codehtml = GetHtmlcode(UrL)
With CreateObject("htmlfile")
.body.innerhtml = Codehtml
For Each oTable In .getelementsbytagname("TABLE") 'boucler chaque tableau
If InStr(1, oTable.innertext, "Bénéfice net par action") > 0 Then Set TableHtmL = oTable 'tableau contient ce texte
Next oTable
If Not TableHtmL Is Nothing Then
Set TRS = TableHtmL.getelementsbytagname("TR")
E = 0
sCurr = ""
For trl = 1 To TRS.Length - 1
A = 3
For C = 1 To 3
E = E + 1
sp = Split(Trim(TRS(trl).Cells(C).innertext)) 'séparer avec l'espace
b = (Right(sp(0), 1) = "%") 'drapeau dernier charactère est %
tbl(LiG, A + (E - 1)) = CDbl(Replace(Left(sp(0), Len(sp(0)) + b), ",", ",")) * IIf(b, 0.01, 1) 'valeur éventuellement divisé par 100 pour les pourcentages
If UBound(sp) >= 1 Then sCurr = sp(1) 'si le currency est connu, mémorisez-le
Next
Next
tbl(LiG, UBound(tbl, 2)) = sCurr 'currency
End If
End With
Next
With Feuil1.Range("tableau_cotations")
.ClearContents
.Value = tbl
End With
Application.StatusBar = False
End Sub
quand je lance j'ai un message d'erreur ici :