Ça doit pouvoir se faire.auriez vous également une solution afin de supprimer ligne dans une cellule qui contient un caractère spécifique (ex buckle, la ligne qui contient ce mot sera supprimée)
Sub Paragraphes()
Application.ScreenUpdating = False
With [C1:C8] 'à adapter
.Replace vbCrLf, vbLf, xlPart
.Replace "." & vbLf, "|"
.Replace vbLf, " "
.Replace "|", "." & vbLf
.ColumnWidth = 255
.Rows.AutoFit
.Columns.AutoFit
End With
End Sub
Voyez ce fichier (2) et la macro :auriez vous également une solution afin de supprimer ligne dans une cellule qui contient un caractère spécifique (ex buckle, la ligne qui contient ce mot sera supprimée)
Sub Paragraphes()
Dim sup$, tablo, i&, s, x$, j%
sup = "buckle" 'à adapter
Application.ScreenUpdating = False
With [C1:C8] 'à adapter
.Replace vbCrLf, vbLf, xlPart
.Replace "." & vbLf, "|"
.Replace vbLf, " "
.Replace "|", "." & vbLf
tablo = .Resize(, 2) 'matrice, plus rapide, au moins 2 éléments
For i = 1 To UBound(tablo)
s = Split(tablo(i, 1), vbLf)
x = ""
For j = 0 To UBound(s)
x = x & IIf(InStr(s(j), sup), "", vbLf & s(j))
Next j
tablo(i, 1) = Mid(x, 2)
Next i
.Value = tablo 'restitution'
.ColumnWidth = 255
.Rows.AutoFit
.Columns.AutoFit
End With
End Sub
Sub Paragraphes()
Dim sup$, tablo, i&, x$, j%, s
sup = "buckle" 'à adapter
Application.ScreenUpdating = False
With [C1:C8] 'à adapter
'---traitement des renvois à la ligne---
.Replace vbCrLf, vbLf, xlPart
.Replace "." & vbLf, "|" 'repère
tablo = .Resize(, 2) 'matrice, plus rapide, au moins 2 éléments
For i = 1 To UBound(tablo)
x = tablo(i, 1)
j = InStrRev(x, "|") 'position du dernier repère
x = Replace(Left(x, j), vbLf, " ") & Mid(x, j + 1)
x = Replace(x, "|", "." & vbLf)
While Right(x, 1) = vbLf: x = Left(x, Len(x) - 1): Wend 'renvois en fin de chaîne
tablo(i, 1) = x
Next i
'---traitement de sup---
For i = 1 To UBound(tablo)
s = Split(tablo(i, 1), vbLf)
x = ""
For j = 0 To UBound(s)
x = x & IIf(InStr(s(j), sup), "", vbLf & s(j))
Next j
tablo(i, 1) = Mid(x, 2)
Next i
'---restitution---
.Value = tablo
.ColumnWidth = 255
.Rows.AutoFit
.Columns.AutoFit
End With
End Sub
Ah bon. Au temps pour moi alors.Non cêst bien cela ^^