How to Remove Carriage Returns in Excel: 3 Easy Ways

In this article, we will discuss some methods to remove carriage returns in Excel; including VBA. Often, we copy data from web pages or other workbooks, which contain carriage returns, line breaks with Alt+Enter. Later, if required, we have to remove these carriage returns and line breaks. Luckily, Excel has very easy options to delete these line breaks and now we will discuss those.


How to Remove Carriage Returns in Excel: 3 Easy Ways

1. Delete Carriage Returns Using Find and Replace

We can remove carriage returns manually by Find and Replace option. For example, we have a dataset containing book names with carriage returns.

Steps:

  • At first, select the cells containing line breaks.

Delete Carriage Returns Using Find and Replace

  • Then, press Ctrl+H from the keyboard. As a result, the Find and Replace window will pop up. Now, go to Find what field and press Ctrl+J. A dot (.) will show up in the box. Keep Replace with field blank. Finally, click the Replace All button.

Delete Carriage Returns Using Find and Replace

  • Consequently, all the line breaks will be removed.

Use of Find and Replace

Read More: How to Insert Carriage Return in Excel Cell


2. Use Excel Functions to Remove Carriage Returns

Excel has some inbuilt functions to remove line breaks. In this method, we will use the combination of SUBSTITUTE and CHAR functions.

Steps:

  • At first, consider a dataset containing color names with carriage return.

Use Excel Functions to Remove Carriage Returns

  • Then, type the following formula in a blank cell:
=SUBSTITUTE(B5,CHAR(10),", ")
Use Excel Functions to Remove Carriage Returns

The SUBSTITUTE function replaces existing text with new text in a text string.  However, the CHAR function returns the character specified by the code number from the character set for your computer.

Here, the formula removes line breaks of Cell B5 and replaces those breaks with commas. On the other hand, Char(10) function returns a line break character.

  • Finally, you will get the following result. Use Autofill (+) to copy the formula to other cells.

Use of Functions

Read More: Remove Carriage Return in Excel with Text to Columns


3. Erase Carriage Returns Using VBA in Excel

If you do not want to use manual ways or formulas to remove line breaks, using VBA can be an excellent option. Suppose we have a book name dataset containing carriage returns. We will follow the below steps to delete those breaks.

Erase Carriage Returns Using VBA

Steps:

  • Firstly, go to the sheet containing the dataset and open the code window by clicking the View Code.

Erase Carriage Returns Using VBA

  • Then, write the following code to the code window.
Option Explicit
Sub RemoveCarriageReturns()

Dim MyRange As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each MyRange In ActiveSheet.UsedRange
If 0 < InStr(MyRange, Chr(10)) Then
MyRange = Replace(MyRange, Chr(10), "")
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

Erase Carriage Returns Using VBA

  • Lastly, run the code, and line breaks will be removed.

Use of VBA Code

Read More: How to Find Carriage Return in Excel


Download the Practice Workbook

You can download the practice workbook that we have used to prepare this article.


Conclusion

In this article, we have discussed some easy methods to remove carriage returns in Excel. So, hopefully, these methods will help you. Download and practice our workbook for all the methods mentioned above. If you have any queries, please feel free to comment here.


Related Articles


<< Go Back to Carriage Return | Text Formatting | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Hosne Ara
Hosne Ara

Hosne Ara is a materials and metallurgical engineer who loves exploring Excel and VBA programming. To her, programming is like a time-saving superhero for dealing with data, files, and the internet. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. With a B. Sc. in Materials and Metallurgical Engineering from Bangladesh University of Engineering and Technology, she's shifted gears and now works as a content developer. In this role, she... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo