We can create new line/row inside a cell by pressing ALT+ENTER in MS Excel. If you come across a situation where you want to remove blank rows/lines inside the cell, then you can’t remove them using trim method. Below code helps you to remove them automatically using VBA code.
Sub removeBlankRowsInsidecell() Dim cellWithBlankRows, cellWithoutBlankRows 'Remove blank rows inside cell cellWithBlankRows = ActiveCell.Value ' example cellWithoutBlankRows = Replace(cellWithBlankRows, Chr(10), "") ' removing blank lines inside cell End Sub
In the above code Chr(10) is the new line character.