'Bonsoir,
'je fais une modification (t(i, 4) = t(i, 3) / t(i - 1, 3)); ((Abs(t(i, 4)) < 0.85 And Abs(t(i, 4)) > 1.15) Then '(entre 85% et 115%) à adapter pour 'indiquer l'écart acceptable pour considérer que les points sont sur la même droite).
Sub aargh()
Dim valc()
dl = Cells(Rows.Count, 1).End(xlUp).Row
ReDim valc(1 To dl, 1 To 1)
Range("C1").Resize(dl, 3).Clear
t = Range("A1").Resize(dl, 5).Value
For i = 2 To dl
t(i, 3) = (t(i, 2) - t(i - 1, 2)) / (t(i, 1) - t(i - 1, 1))
Next i
For i = 3 To dl
't(i, 4) = t(i, 3) - t(i - 1, 3)
t(i, 4) = t(i, 3) / t(i - 1, 3)
Next i
For i = 1 To dl
If (Abs(t(i, 4)) < 0.85 And Abs(t(i, 4)) > 1.15) Then '(entre 85% et 115%) à adapter pour indiquer l'écart acceptable pour considérer que les points sont sur la même droite.
t(i, 5) = 0
Else
t(i, 5) = 1
End If
Next i
i = 1
Do While t(i, 5) = 0
i = i + 1
Loop
debut = i - 1
Do While t(i, 5) = 1 Or i < d1
i = i + 1
Loop
If i > dl Then
MsgBox "pas trouvé dintervalle linéaire":
Else
fin = i
Range("f2") = t(debut, 1)
Range("f3") = t(fin, 1)
stat = Application.LinEst(Range(Cells(debut, 2), Cells(fin, 2)), Range(Cells(debut, 1), Cells(fin, 1)), , True)
MsgBox "intervalle linéaire trouvé entre x=" & t(debut, 1) & " et " & t(fin, 1) & vbCrLf & _
"équation de la droite y = " & stat(1, 1) & "x + " & stat(1, 2) & vbCrLf & _
"Coefficient de correlation R² " & stat(3, 1)
Range("g2") = Range("f2") * stat(1, 1) + stat(1, 2)
Range("g3") = Range("f3") * stat(1, 1) + stat(1, 2)
'For i = 1 To dl
'valc(1, 1) = x * stat(1, 1) + stat(1, 2)
'Next i
'Range("C1").Resize(dl, 1) = valc
End If
End Sub