Private Sub CommandButton_valider_Click()
Dim fl As Worksheet, Sheettarget As Worksheet, lastrow As Long
For Each fl In Worksheets
If IsNumeric(fl.Name) Then
With fl
Set trouve = .Range("A:A").Find(Me.no_kalilab, lookat:=xlWhole) 'on regarde déjà si le numéro existe dans la feuille
If trouve Is Nothing Then
MsgBox "N° KALILAB n'existe pas", vbOKOnly + vbInformation, ERREUR
Exit For 'ATTENTION: si le numéro n'existe pas dans la feuille, on sort du for = sort de la macro ==> on ira pas voir si le numéro existe dans une autre feuille
'= on suppose que si un numéro est présent, il doit etre présent dans TOUTES les feuilles
End If
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row 'il faut trouver la dernière ligne du bloc de la pompe sélectionnée
i = lastrow
While .Range("A" & i) <> no_kalilab.Value 'en partant du bas. on remonte jusqu'à trouver le Matériel
i = i - 1 'enregistrement ligne
Wend
pos = Application.Match(CLng(Date), .Rows(6), 0) 'récupère la position de la date du jour dans la ligne 6
If Not IsError(pos) Then 'si trouvée
If OptionButton_chantier Then .Cells(trouve.Row, pos) = "C"
If OptionButton_Stock Then .Cells(trouve.Row, pos) = "S"
If OptionButton_Réparation Then .Cells(trouve.Row, pos) = "R"
If OptionButton_Etalonnage Then .Cells(trouve.Row, pos) = "E"
End If
End With
End If
Next fl
End Sub