Remove blank rows inside cell [excel VBA]

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.


About the Author


A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published. Required fields are marked *