1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Private Sub Worksheet_Change(ByVal Target As Range)
Const Nbmax As Byte = 20
Dim LeMot As String, LaPart
Dim i As Integer
Dim tb
If Target.Count = 1 And Target.Column = 1 Then
LeMot = Target.Value
If Len(LeMot) > Nbmax Then
tb = Split(LeMot, " ")
LaPart = vbNullString: i = LBound(tb)
Do While Len(LaPart) < Nbmax And i < UBound(tb)
LaPart = LaPart & " " & tb(i)
i = i + 1
Loop
LeMot = Trim(Mid(LeMot, Len(LaPart) + 1))
Application.EnableEvents = False
Target.Value = Trim(LaPart)
Application.EnableEvents = True
Target.Offset(1, 0) = LeMot
End If
End If
End Sub |
Partager