In this tip you'll find 3 ways to remove carriage returns from Excel cells. You'll also learn how to replace line breaks with other symbols. All solutions work for Excel 2016, 2013 - 2003
There can be different reasons for line breaks occurring in your text. Usually, carriage returns appear when you copy text from a webpage, get a workbook that already contains line breaks from a customer, or you add them yourself using Alt+Enter.
Remove line breaks in Excel You already know that you can enter a forced line break within a cell by pressing ALT+ENTER, right? If you you want to get rid of the line break you can simply click immediately before the line break and press Delete or click immediately after the line break and press Backspace.
In any case, what you want to do now is delete carriage returns since they don't let you find a phrase and make column contents look disorganized when you turn on the wrap text option.
All these 3 ways are really quick. Feel free to pick the one that suites you best:
Computers and text processing software were created taking into consideration the typewriter specificities. That's why two different non-printable symbols are used now to indicate line break: 'Carriage return' (CR, ASCII code 13) and 'Line Feed' (LF, ASCII code 10). Windows uses 2 symbols one by one: CR+LF, and LF for *NIX systems.
Be careful: in Excel you can find both variants. If you import data from a .txt or .csv file, you are more likely to find Carriage Return + Line Feed. When you break a line using Alt+Enter , Excel inserts Line Feed only. In case you get .csv files from a person who uses Linux, Unix, etc., you'll find only Line Feeds again.
Pros: the fastest way.
Cons: no any additional features :(.
Please find the steps for eliminating line breaks using Find and Replace:
Pros: you can use a formula chain / nested formulas for complex cell text processing. For example, it is possible to remove carriage returns and then eliminate excess leading and trailing spaces and those between words.
Or you may need to delete carriage returns to use your text as an argument of another function without changing the original cells. For example, if you want to be able to use the result as an argument of the function =lookup ().
Cons: you'll need to create a helper column and follow many extra steps.
=SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),'),CHAR(10),')
=TRIM(SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),'),CHAR(10),', ')
=CLEAN(B2)
Pros: Being created once, can be reused in any workbook.
Cons: you need to have the basic knowledge of VBA.
The VBA macro from the example below deletes carriage returns from all cells in the currently opened worksheet (active worksheet).
If you don't know VBA really well, see How to insert and run VBA code in Excel
If you are a lucky user of our Text Toolkit or Ultimate Suite for Excel, then you do not need to waste time on any of the above manipulations. All it takes is these 3 quick steps:
In our example, we are replacing each line break with a space, so you put the mouse cursor in the box and press the Enter key:
As the result, you will have a neatly organized table with one-line addresses:
If you are curious to try this and 60 more time-saving tools for Excel, you are welcome to download a trial version of our Ultimate Suite. You will be amazed to discover a-few-clicks solutions for the most challenging and tedious tasks in Excel!