Sub Test()
Dim myRange As Range, y As Integer, z As Byte, Nb As String
Dim a%, Minx!, Maxx!, min!, max!
'recherche valeur max colonne A pour le calcul du temps
y = Cells.Find("*", , xlValues, , 1, 2, 0).Row 'Dernière ligne
z = Cells.Find("*", , xlValues, , 2, 2, 0).Column 'Dernière colonne
Set myRange = Range("A1", Cells(y, z))
Nb = Application.WorksheetFunction.max(myRange)
Range("G1").Value = Nb / 10
'MsgBox "la valeur max est " & Nb
min = 1000
For a = 0 To Range("G1").Value
If (Range("b4").Offset(a, 0).Value) < (min + 0.5) Then
min = Range("b4").Offset(a, 0).Value
Minx = Range("b4").Offset(a, -1).Value
End If
If (Range("b4").Offset(a, 0).Value) > (max + 0.5) Then
max = Range("b4").Offset(a, 0).Value
Maxx = Range("b4").Offset(a, -1).Value
End If
Next
Range("G2").Value = min
Range("G4").Value = Minx
Range("G3").Value = max
Range("G5").Value = Maxx
Range("G6").Value = (Maxx - Minx) / 100
Range("G7").Value = max - min
End Sub
Function PremierPoint(tablo As Range, colonne As Byte)
Dim Necartype As Byte, i&, P As Range
Necartype = 5 'paramétrable
For i = 2 To tablo.Rows.Count
Set P = Range(tablo(1, 2), tablo(i, 2))
If tablo(i, 2) > Application.Average(P) + Necartype * Application.StDev(P) Then _
PremierPoint = tablo(i, IIf(colonne = 1, 1, 2)): Exit For
Next
End Function
Function DernierPoint(tablo As Range, colonne As Byte)
Dim Necartype As Byte, trc&, i&, P As Range
Necartype = 5 'paramétrable
trc = tablo.Rows.Count
For i = trc - 1 To 1 Step -1
Set P = Range(tablo(trc, 2), tablo(i, 2))
If tablo(i, 2) < Application.Average(P) - Necartype * Application.StDev(P) Then _
DernierPoint = tablo(i, IIf(colonne = 1, 1, 2)): Exit For
Next
End Function
Function PremierPoint(tablo As Range)
Dim Necartype As Byte, i&, P As Range
Necartype = 5 'paramétrable
For i = 2 To tablo.Rows.Count
Set P = Range(tablo(1, 2), tablo(i, 2))
If tablo(i, 2) > Application.Average(P) + Necartype * Application.StDev(P) Then _
PremierPoint = tablo(i, 1): Exit For
Next
End Function
Function DernierPoint(tablo As Range)
Dim Necartype As Byte, trc&, i&, P As Range
Necartype = 5 'paramétrable
trc = tablo.Rows.Count
For i = trc - 1 To 1 Step -1
Set P = Range(tablo(trc, 2), tablo(i, 2))
If tablo(i, 2) < Application.Average(P) - Necartype * Application.StDev(P) Then _
DernierPoint = tablo(i, 1): Exit For
Next
End Function
Function PremierPoint(debtemps As Range, colonne As Range)
Dim Necartype As Byte, h&, tablo As Range, i&, P As Range
Necartype = 5 'paramétrable
h = Cells(Rows.Count, colonne.Column).End(xlUp).Row - debtemps.Row + 1
Set tablo = debtemps.Offset(, colonne.Column - debtemps.Column).Resize(h)
For i = 2 To h
Set P = Range(tablo(1), tablo(i))
If tablo(i) > Application.Average(P) + Necartype * Application.StDev(P) Then _
PremierPoint = debtemps(i): Exit For
Next
End Function
Function DernierPoint(debtemps As Range, colonne As Range)
Dim Necartype As Byte, h&, tablo As Range, i&, P As Range
Necartype = 5 'paramétrable
h = Cells(Rows.Count, colonne.Column).End(xlUp).Row - debtemps.Row + 1
Set tablo = debtemps.Offset(, colonne.Column - debtemps.Column).Resize(h)
For i = h - 1 To 1 Step -1
Set P = Range(tablo(h), tablo(i))
If tablo(i) < Application.Average(P) - Necartype * Application.StDev(P) Then _
DernierPoint = debtemps(i): Exit For
Next
End Function