Sub ajustComm()
Dim pl As Range, c As Range, ch As String
Set pl = Selection.Cells.SpecialCells(xlCellTypeComments)
Application.ScreenUpdating = False
If Not pl Is Nothing Then
For Each c In pl
c.Comment.Text decoupCh(c.Comment.Text, 80)
c.Comment.Shape.TextFrame.AutoSize = True
Next c
End If
End Sub
Function decoupCh(ch As String, lMax As Long, Optional suppVbLF = False) As String
Dim pos As Long, tmp, i As Long
'insère chr(10) tous les x caractères, sans couper les mots
If ch <> "" And InStr(ch, " ") > 0 Then
If suppVbLF Then ch = Replace(ch, vbLf, " ")
tmp = Split(ch, vbLf)
For i = 0 To UBound(tmp)
If tmp(i) <> "" Then
pos = lMax + 1
Do
pos = InStrRev(tmp(i), " ", pos)
If pos = 0 Then Exit Do
Mid(tmp(i), pos, 1) = vbLf
pos = pos + lMax + 1
Loop Until pos >= Len(tmp(i))
End If
Next i
End If
decoupCh = Join(tmp, vbLf)
End Function