Paragraph2Line + Line2Paragraph

Converts paragraph to 1 line text or 1 line text to paragraph
Mainly used to convert multi-line text inside Excel cell into 1 line text or into full paragraph (with regular Enter)
Paragraph2Line(Cell1.value,,1) to convert excel cell into 1 line text with {{$C$}} as line separator
Line2Paragraph(Paragraph2Line(Cell1.value,,1)) to convert Excel cell with multi-line text into regular paragraph

Function Paragraph2Line(ParagraphText, Optional Sepa = "{{$C$}}", Optional ExcelCell=0)
' ExcelCell = 1 if ParagraphText comes from Excel Cell
OldSep1 = vbcrlf
If ExcelCell = 1 then OldSep1 = vbLf
Paragraph2Line = Replace(ParagraphText, OldSep1, Sepa)
End Function
Function Line2Paragraph(LineText, Optional Sepa = "{{$C$}}", Optional ExcelCell=0)
' ExcelCell=1 if we want to convert to Excel Cell, not regular block
' Regular block has vbcrlf as row separator
' Excel Cell has it as vbLf
OldSep1 = vbCrLf
If ExcelCell=1 then OldSep1 = vbLf
Line2Paragraph = Replace(LineText, Sepa, OldSep1)
End Function

ParagraphText, Optional Sepa = "{{$C$}}", Optional ExcelCell=0
LineText, Optional Sepa = "{{$C$}}", Optional ExcelCell=0

Views 1844 Downloads 763

Texts + Strings VBA-Excel