Sub courrrs()
x = cours("11/11/2011", "11/07/2012", "BCP ")
End Sub
Function cours(datdeb As String, datfin As String, ticker As String) As String
Dim i As Integer, j As Integer, k As Integer, l As Integer
i = 2
While CDate((Feuil2.Cells(i, 1)) <= CDate(datdeb)) And (i <= CInt(Feuil3.Range("B2")))
i = i + 1
Wend
MsgBox (i)
If CDate(datdeb) = (Feuil2.Cells(i - 1, 1)) Then
j = i - 1
Else
m = InputBox("La date la plus proche est " & Feuil2.Cells(i - 1, 1) & " écrire oui pour l'utiliser")
j = i - 1
End If
While (CDate(Feuil2.Cells(i, 1)) <= CDate(datfin)) And (i <= CInt(Feuil3.Range("B2")))
i = i + 1
Wend
MsgBox (i)
If CDate(datfin) = CDate(Feuil2.Cells(i - 1, 1)) Then
k = i - 1
Else
m = InputBox("La date la plus proche est " & Feuil2.Cells(i - 1, 1) & " écrire oui pour l'utiliser")
k = i - 1
End If
indticker = Application.WorksheetFunction.HLookup(ticker, Feuil3.Range("D1" & ":" & "CC2"), 2, False)
For l = j To k
Feuil20.Cells(l - j + 1, 1) = CDate(Feuil2.Cells(l, 1))
Feuil20.Cells(l - j + 1, 2) = CDbl(Feuil2.Cells(l, indticker))
Next l
Feuil20.Activate
cours = "fait"
End Function