Sub Etude_Serie1()
Dim x1, x2, x3, x4, debut&, fin&, a, m, b, seb, decal, i&
x1 = -30
x2 = -20
x3 = -10
x4 = 10
With [A1].CurrentRegion
debut = Application.Match(x1, .Columns(1))
fin = Application.Match(x2, .Columns(1))
Range(.Cells(debut, 1), .Cells(fin, 1)).Name = "X"
Range(.Cells(debut, 2), .Cells(fin, 2)).Name = "Y"
a = [LINEST(Y,X,1,1)]
m = Application.Index(a, 1, 1)
b = Application.Index(a, 1, 2)
seb = Application.Index(a, 2, 2)
decal = 5
For i = fin To .Rows.Count
If .Cells(i, 2) > m * .Cells(i, 1) + b + decal * seb Then
MsgBox "1ère butée au point " & i & " d'abscisse " & .Cells(i, 1), , "Série1"
Exit For
End If
Next i
debut = Application.Match(x3, .Columns(1))
fin = Application.Match(x4, .Columns(1))
Range(.Cells(debut, 1), .Cells(fin, 1)).Name = "X"
Range(.Cells(debut, 2), .Cells(fin, 2)).Name = "Y"
a = [LINEST(Y,X,1,1)]
m = Application.Index(a, 1, 1)
b = Application.Index(a, 1, 2)
seb = Application.Index(a, 2, 2)
decal = 38
For i = fin To .Rows.Count
If .Cells(i, 2) > m * .Cells(i, 1) + b + decal * seb Then
MsgBox "2ème butée au poinr " & i & " d'abscisse " & .Cells(i, 1), , "Série1"
Exit For
End If
Next i
End With
End Sub
Sub Etude_Serie2()
Dim x1, x2, x3, x4, debut&, fin&, a, m, b, seb, decal, i&
x1 = 30
x2 = 20
x3 = 10
x4 = -10
With [D1].CurrentRegion
debut = Application.Match(x1, .Columns(1), -1)
fin = Application.Match(x2, .Columns(1), -1)
Range(.Cells(debut, 1), .Cells(fin, 1)).Name = "X"
Range(.Cells(debut, 2), .Cells(fin, 2)).Name = "Y"
a = [LINEST(Y,X,1,1)]
m = Application.Index(a, 1, 1)
b = Application.Index(a, 1, 2)
seb = Application.Index(a, 2, 2)
decal = 0
For i = fin To .Rows.Count
If .Cells(i, 2) < m * .Cells(i, 1) + b - decal * seb Then
MsgBox "1ère butée au point " & i & " d'abscisse " & .Cells(i, 1), , "Série2"
Exit For
End If
Next i
debut = Application.Match(x3, .Columns(1), -1)
fin = Application.Match(x4, .Columns(1), -1)
Range(.Cells(debut, 1), .Cells(fin, 1)).Name = "X"
Range(.Cells(debut, 2), .Cells(fin, 2)).Name = "Y"
a = [LINEST(Y,X,1,1)]
m = Application.Index(a, 1, 1)
b = Application.Index(a, 1, 2)
seb = Application.Index(a, 2, 2)
decal = 16
For i = fin To .Rows.Count
If .Cells(i, 2) < m * .Cells(i, 1) + b - decal * seb Then
MsgBox "2ème butée au poinr " & i & " d'abscisse " & .Cells(i, 1), , "Série2"
Exit For
End If
Next i
End With
End Sub