Using Excel v16
I'm trying to format text in a cell by replacing a character like tilde ~ with a carriage return whereby the finished result would be multiple lines. This is actually a merged cell of multiple rows and columns as shown below
Here is the script I'm using in my macro
Sub FindReplaceAll()
Sheets("Template").Select
Range("A34").Select
iStr = ActiveCell.Value
For i = 1 To Len(iStr)
If Mid(iStr, i, 1) = "~" Then
rtStr = rtStr + vbCr
Else
rtStr = rtStr + Mid(iStr, i, 1)
End If
Next i
ActiveCell.Value = rtStr
End Sub
Unfortunately all I get is same line with the tilde removed The cell is formatted with the wrap text. Not sure where to go from here.


Sheets("template").Range("A34").Value = Replacc(Sheets("template").Range("A34").value, "~", chr(10))That will set that cell's value to itself, but replacing the tildes with a carriage return. As mentioned in the answer below you can usevbcrlffor a carriage return/line feed orchr(10) & chr(11)if you want to split hairs.