Private Sub Worksheet_Change(ByVal Target As Range)
Dim ncol%, tablo, ub&, i&, n&, j%, k&
With UsedRange
ncol = .Columns.Count
If ncol = 1 Then ncol = 2 'sécurité
tablo = .Resize(.Rows.Count + 1, ncol)
ub = UBound(tablo) - 1
ReDim resu(1 To UBound(tablo) + 4 * Application.CountIf(.Columns(2), "Oui"), 1 To ncol)
For i = 1 To UBound(tablo) - 1
If Not LCase(tablo(i, 1)) Like "enfant#" Then
n = n + 1
For j = 1 To ncol
resu(n, j) = tablo(i, j)
Next j
If LCase(tablo(i, 2)) = "oui" Then
If LCase(tablo(i + 1, 1)) Like "enfant#" Then
For k = i + 1 To ub
n = n + 1
For j = 1 To ncol
resu(n, j) = tablo(k, j)
Next j
If Not LCase(tablo(k, 1)) Like "enfant#" Then Exit For
Next
i = k
Else
For k = 1 To 4
n = n + 1
resu(n, 1) = "Enfant" & k
Next k
End If
End If
End If
Next i
Application.ScreenUpdating = False
Application.EnableEvents = False 'désactive les évènements
If FilterMode Then ShowAllData 'si la feuille est filtrée
.Value = Empty 'RAZ
.Cells(1).Resize(n, ncol) = resu 'restitution
Application.EnableEvents = True 'réactive les évènements
End With
With UsedRange: End With 'actualise les barres de défilement
End Sub