Bonjour,
Avec la macro ci-dessous (Merci forum Excel Download) je récupère très bien les cours de mes actions.
Cependant, seules 2 décimales sont affichées, et j'aurai besoin d'en récupérer 4 dans Cotation.
Quelqu'un peut-il m'aider ? Merci par avance.
Sub MajCotations()
Dim i%, k%, URL$, COT
k = Cells(Rows.Count, [REF].Column).End(xlUp).Row
Range(Cells(2, [Cotation].Column), Cells(k, [Cotation].Column)).Clear
avant = """price"":"
apres = ","
On Error Resume Next
For i = 2 To k
DoEvents
ReDim COT(1 To k, 1 To 1)
COT(1, 1) = Cells(i, [Cotation].Column).Value
URL = Cells(i, [WWW].Column).Value
Application.StatusBar = "Mise à jour des cotations en cours …"
On Error Resume Next
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
If .Status = 200 Then COT(i, 1) = Split(Split(.responseText, avant)(1), apres)(0)
End With
Application.StatusBar = False
Cells(i, [Cotation].Column).Value = COT(i, 1)
End Sub
Avec la macro ci-dessous (Merci forum Excel Download) je récupère très bien les cours de mes actions.
Cependant, seules 2 décimales sont affichées, et j'aurai besoin d'en récupérer 4 dans Cotation.
Quelqu'un peut-il m'aider ? Merci par avance.
Sub MajCotations()
Dim i%, k%, URL$, COT
k = Cells(Rows.Count, [REF].Column).End(xlUp).Row
Range(Cells(2, [Cotation].Column), Cells(k, [Cotation].Column)).Clear
avant = """price"":"
apres = ","
On Error Resume Next
For i = 2 To k
DoEvents
ReDim COT(1 To k, 1 To 1)
COT(1, 1) = Cells(i, [Cotation].Column).Value
URL = Cells(i, [WWW].Column).Value
Application.StatusBar = "Mise à jour des cotations en cours …"
On Error Resume Next
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
If .Status = 200 Then COT(i, 1) = Split(Split(.responseText, avant)(1), apres)(0)
End With
Application.StatusBar = False
Cells(i, [Cotation].Column).Value = COT(i, 1)
End Sub