Sub precision_interne234U()
Dim j As Integer
Dim i As Integer
Dim moy As Double
Dim SD As Double
Dim moy2 As Double
Dim SD2 As Double
Dim test As Double
With Sheets("XXXX")
'on nomme les cellules de début ou l'on mettra les différents résultat
.Cells(57, 2) = "moyenne"
.Cells(58, 2) = "StandDev(x2)"
.Cells(59, 2) = "SD%"
'boucle for qui permettra de parcourir les colonne et donc de faire les isotopes 234U à 238U qui sont des colonnes 3 à 6, on parcours donc les colonnes 3 à 6
For j = 3 To 9
moy = Application.Average(.Range(.Cells(24, j), .Cells(53, j)).Value)
SD = Application.StDev(.Range(.Cells(24, j), .Cells(53, j)).Value)
moytest = Application.Average(.Range(.Cells(24, j), .Cells(53, j)).Value)
SDtest = Application.StDev(.Range(.Cells(24, j), .Cells(53, j)).Value) + 1
'paramètre de test arbitraire on fera des test pour voir ce qui est le plus adequat 50%, 75% 80% etc
Do Until SDtest - SD = 0
'on parcours les lignes 24 à 53 où les 30 mesures d'un isotope sont avec la boucle for
For i = 24 To 53
If .Cells(i, j) >= 2 * SD + moy Then .Cells(i, j) = Empty
If .Cells(i, j) <= 2 * SD - moy Then .Cells(i, j) = Empty
Next
'on stocke l'ancienne moyenne et l'ancien SD dans les variables XXXtest pour faire ensuite le test du while
moytest = moy
SDtest = SD
moy = Application.Average(.Range(.Cells(24, j), .Cells(53, j)).Value)
SD = Application.StDev(.Range(.Cells(24, j), .Cells(53, j)).Value)
Loop
'on calcule les moy et SD finaux et on les affiche dans tel ou tel colonnes/lignes correspondante
moyfinal = Application.Average(.Range(.Cells(24, j), .Cells(53, j)).Value)
SDfinal = Application.StDev(.Range(.Cells(24, j), .Cells(53, j)).Value) * 2
.Cells(57, j).Value = moyfinal
.Cells(58, j).Value = SDfinal
.Cells(59, j).Value = (SDfinal / moyfinal) * 100
Next
End With
End Sub