How to: Remove or replace line breaks and carriage returns in cells

There are few quick methods to remove the line breaks and carriage returns in cells.
By default you might not know an easy and quick way to do this but it is fairly simple, either with just Excel, or with the help of ASAP Utilities.

Let's say we have the following example.
In this case the author has used the shortcut Alt+Enter to put the last name on a new line.Initial dataset
But now we need it together on a single line, with a space between the first- and last name instead of a line break.
Instead of:
Bastien
Mensink

we need
Bastien Mensink, etc. etc.

Method 1, with Excel only

If you want to replace these line-breaks with for example a space, you can do this with Excel's find/replace command.

In the "Find what:" box you can enter the line-break code, which is character number 10.
To do this, press and hold the Alt key, and then enter the numbers 010 from the numeric part of the keyboard.
On my computer in the box there is then a small dot blinking when the cursor is still in the entry box.
To enter the numbers you need to use the numbers from the Num-lock part of the keyboard (with the numbers above the letters on your keyboard it doesn't work). If you have data imported from another source, sometimes the line breaks are also represented by character 13 instead of 10.

In the "Replace with:" dialog you can enter a space to have the line-breaks replaced with spaces. You can also leave that blank to have the line-breaks removed.
Excel's Find and Replace dialogue

Method 2, with ASAP Utilities

You can use the following tool from ASAP Utilities to remove or replace the line-breaks:
Text » Advanced character remove or replace...

In the dialogue you can click on the "Line breaks" button to remove or replace the line break characters in the selected cells:Remove the line breaks/carriage returns with ASAP Utilities

Method 3, with ASAP Utilities

You can use the following tool from ASAP Utilities to remove or replace the line-breaks:
Range » Find and/or replace in all sheets...

To search for the line break you can enter the code {lf}, to search for the carriage return you can use {cr}:ASAP Utilities Find and/or replace in all sheets

3 comments

Dave

You can also use ctrl-j instead of alt-0010 in excel's edit|replace dialog.

Bastien

Hello Dave,

Thank you for your feedback.
I didn't know that, thanks for sharing!

Kind regards,
Bastien

Kanwaljit

Hi Bastien,

May the Couple Live 1000 years !

If we put , (comma) when using the File Types option "Text File, Delimited by :" in Utility 16-Import->10 Merge and Import Multiple Files" the Utility starts a give an error message "Error 1004 : Method ~ of Object ~ Failed". Other file type options seems to be working fine.

Regards
CA Kanwaljit Singh Dhunna