Re : Séparation chaine caractères ts les X caracteres avec retour à la ligne suivante
Bonjour,
J'ai trouvé le code un peu confu, j'ai essayé de le simplifier.
Bon courage.
Option Explicit
' Macro adaptée d'un code de Job75
Sub DecoupeLigne(max As Integer)
Dim cel As Range, Txt$, Txt2$
Dim i As Integer, Iterations As Integer
With Sheets("original") 'à adapter
max = 60
For Each cel In Range("B1", [B65536].End(xlUp))
Txt = cel 'texte à découper
Txt2 = cel.Offset(0, -1) 'indice
'***on insère le bon nombre de lignes
Iterations = Int((Len(Txt) - 1) / max)
If Iterations > 0 Then
Rows(cel.Row + 1 & ":" & (cel.Row + Iterations)).Insert shift:=xlUp
End If
'*** on écrit le texte
For i = 0 To Iterations
cel.Offset(i, 0).Value = Mid(Txt, (i * max) + 1, max)
Next i
Next cel
End With
End Sub