Private Sub Worksheet_Change(ByVal Target As Range)
Dim maxi, c As Range, s, t$, e, i%, t1$
Application.EnableEvents = False 'désactive les évènements
With [M1] 'nombre maximun de caractères d'une ligne en C2, à adapter
.Value = Abs(Int(Val(.Value)))
maxi = .Value
If Target.Address = .Address Then .Select
End With
Application.ScreenUpdating = False
Rows("3:" & Rows.Count).Delete 'RAZ
Rows("3:" & Rows.Count).WrapText = False 'pas de renvoi à la ligne
For Each c In [A2:B2,D2:G2] 'plage à adapter
s = Split(Replace(Replace(c, vbLf, " "), " %", "%"))
If c <> "" Then c(2).Resize(UBound(s) + 1) = Application.Transpose(s)
Next c
Set c = [C2] 'cellule à adapter
If c <> "" Then
t = ""
For Each e In Split(Replace(c, vbCrLf, " "))
s = Split(e, vbLf)
For i = 0 To UBound(s)
t1 = t
t = Trim(t & IIf(i, vbLf, " ") & s(i))
If Len(t) - InStrRev(t, vbLf) > maxi Then t = t1 & IIf(i, vbLf, vbCrLf) & s(i)
Next i, e
c = t 'nouveau texte en C2
s = Split(Replace(t, vbCrLf, vbLf), vbLf)
c(2).Resize(UBound(s) + 1) = Application.Transpose(s)
End If
Columns("C").AutoFit 'ajustement largeur
Rows(2).AutoFit 'ajustement hauteur
Application.EnableEvents = True 'réactive les évènements
End Sub