Sub travdem()
Dim Cellule As Range
Dim Nomfeuille1 As String
Dim col As String
Dim Colstatut As String
Dim I As Byte, J As Byte, K As Long, I1 As Byte
Dim Statut As String
' pour boucler sur la colonne 1
' paramétrage
Nomfeuille1 = "BEC 2"
col = "A"
Colstatut = "K"
'
With Sheets(ActiveSheet.Name)
I1 = 0
For Each Cellule In .Range(col & "11:" & col & .Range(col & .Rows.Count).End(xlUp).Row)
If I1 = 0 Then
For I = 1 To 100
If Cellule.Offset(I, 0) <> Cellule Then Exit For
Next I
I = I - 1
I1 = I
If I > 0 Then
If I = 1 Then
.Range(Colstatut & Cellule.Row) = .Range(Colstatut & Cellule.Row + I)
Else
'Si tous les sous chapitres ont un statut OK,
'l’item général sera OK, si un des sous chapitres à un statut «en cours»,
'le statut de l’item général sera en cours, '
'si un des sous chapitre est en NOK, le statut général sera en NOK.
For J = 1 To I
Statut = ""
Select Case .Range(Colstatut & Cellule.Row + J)
Case "NOK"
Statut = "NOK"
Exit For
Case "En cours"
Statut = "En cours"
Exit For
Case "OK"
Statut = "OK"
Case ""
Statut = ""
Exit For
Case Else
Statut = ""
Exit For
End Select
Next J
.Range(Colstatut & Cellule.Row) = Statut
End If
End If
Else
I1 = I1 - 1
End If
Next Cellule
End With
End Sub