J'ai essayer de mettre le code sur une autre feuille, il ne fonctionne pas.
Sub MajCotations()
Dim i%, k%, URL$, avant1$, avant2$, apres1$, apres2$, indice%
On Error Resume Next
For i = 2 To Cells(Rows.Count, "B").End(xlUp).Row
DoEvents
URL = Cells(i, "B").Value
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
If .Status = 200 Then
For k = 1 To 4
avant1 = Sheets("paramètres").Range("avant1").Offset(0, k).Value
apres1 = Sheets("paramètres").Range("apres1").Offset(0, k).Value
avant2 = Sheets("paramètres").Range("avant2").Offset(0, k).Value
apres2 = Sheets("paramètres").Range("apres2").Offset(0, k).Value
Cells(i, "B").Offset(0, k).Value = Replace(mydata(.responseText, avant1, apres1, avant2, apres2), Chr(10), "")
Next
Cells(i, "B").Offset(0, k).Value = Date
End If
End With
Next
End Sub
Function mydata(texte As String, debut1 As String, fin1 As String, debut2 As String, fin2 As String)
mydata = Split(Split(texte, debut1)(1), fin1)(0)
If debut2 <> "" And fin2 <> "" Then mydata = Split(Split(mydata, debut2)(1), fin2)(0)
End Function