How to Insert and Remove Carriage Return in Excel

A carriage return is also known as a line break in an Excel cell. While they are technically different, the traditional meaning of carriage return from typewriters is rarely used in modern operating systems.

In the following image, we have used the CHAR(10) with other functions to add carriage returns. For example, in Cell E5, we used the ampersand (&) operator to join cells B5, C5, and D5. We also applied the CHAR(10) function to add carriage returns after cells B5 and C5.

carriage return in Excel


What is Carriage Return?
Insert Carriage Return in Excel
 ⏵Use Keyboard Shortcuts
 ⏵Merge CHAR, CONCATENATE & TEXTJOIN Functions
 Use Find and Replace Feature
 Apply VBA Code
Remove Carriage Return
 Use Find and Replace Feature
 Merge TRIM and SUBSTITUTE Functions
 ⏵Use VBA Code
Tips for Carriage Return in Excel
Things to Remember
Frequently Asked Questions
Carriage Return in Excel: Knowledge Hub


What Is a Carriage Return?

Carriage return adds a line break within a single cell instead of using multiple cells. It is also known as the return or line feed character. ASCII code 10 represents the character for Windows.

The Wrap Text feature offers similar functionality, however it doesn’t always allow the line to break in the desired position. Adding a carriage return puts the line break where we want it to be.


How to Insert a Carriage Return in Excel

Method 1 – Using Keyboard Shortcuts

  • Select the cell and press the F2 key to enter edit mode.
  • Place the cursor where you want to add a carriage return and press Alt+Enter on your keyboard. For Mac, use Control+Option+Return or Control+Command+Return.

using keyboard shortcut

The carriage return or line break will occur at that place.

one carriage return added

  • Do this for every carriage return required in the cell.

two carriage returns added


Method 2 – Using Excel CHAR, CONCATENATE, and TEXTJOIN Functions

The character used for carriage return is different in Windows and Mac. For Windows it is CHAR(10), and for Mac it is CHAR(13). We can combine this character with other functions to get a carriage return.

In this example, we show the formulas for Windows. Simply replace CHAR(10) with CHAR(13) for Mac.

  • Use the following function with ampersand to produce a string including a carriage return:
=B5&" "&CHAR(10)&C5&" "&CHAR(10)&D5
=CONCATENATE(B6,CHAR(10),C6,CHAR(10),D6)
=TEXTJOIN(CHAR(10),TRUE,B7:D7)

formulas to add carriage return in excel

Note: You must use the Wrap Text feature in each cell after using the formula. To do so, go to the Home tab >> Alignment section >> select Wrap Text.

Method 3 – Using the Find and Replace Feature

If you have a worksheet with multiple one-line entries, you may need to break lines to use the data easily. To save yourself the tedious and time-consuming task of doing this manually, use the Find and Replace feature.

In this method, we have some data in cells separated by commas. We will add a carriage return in place of a comma.

  • Press Ctrl+H to open the Find and Replace dialog box.
  • Select the character you want to replace with a carriage return. We are replacing “, “, so we put that in the Find what field.
  • In the Replace with field, press Ctrl+J. This will insert the carriage return in that field.

find and replace feature

  • Click on Replace All and resize the cells to get your desired view.

carriage return added with find and replace


Method 4 – Using Carriage Return in VBA

  • Go to the Developer tab and select Visual Basic from the Code group.

opening vba window

  • Select Insert and then Module in the VBA window.
  • Insert the following code in the module:
Sub CRinMacro()
MsgBox "First Line" & vbCrLf & "Second Line"
End Sub

inserting code in vba

Note: You can use CHAR(10) for the carriage return inside VBA instead of vbCrLf.
  • Press F5 to run the code.

You will get a carriage return where vbCrLf is used.

carriage return in msgbox

Read More: Insert Carriage Return in Excel Cell


How to Remove a Carriage Return in Excel

Carriage returns may appear when you copy texts from a website or use downloaded CSV or Text files in Excel. Carriage returns can be removed from cells in 3 ways:


Method 1 – Using the Find and Replace Feature

  • Open the Find and Replace dialog box by pressing Ctrl+H.
  • Press Ctrl+J to insert the carriage return in the Find what field.
  • Insert the delimiter with which you want to replace the carriage return in the Replace with field.

removing carriage return with find and replace

  • Select Replace All and all the carriage returns in the spreadsheet will be replaced.

carriage return removed with find and replace

Note: With this method, the carriage return can only be replaced by one particular character for all cells.

Method 2 – Using TRIM and SUBSTITUTE Functions

In the dataset below, we have some personal information in Cells B5 and B6. After removing the carriage returns, the results will be like Cell C5 and C6 respectively.

removing carriage return example

  • Combine the TRIM and SUBSTITUTE functions to remove carriage return from a cell as follows:
=TRIM(SUBSTITUTE(SUBSTITUTE(B5,CHAR(13),""),CHAR(10),", "))
  • Use a space in place of the comma if desired.
  • Alternatively, use just the SUBSTITUTE function to replace the carriage return with another character as follows:
=SUBSTITUTE(B6,CHAR(10),", ")
removing carriage return using Excel functions

Click the image to get a detailed view

Note: Use the TRIM or CLEAN functions to remove the carriage returns. However, these functions will not replace them with necessary spaces. For example, to remove carriage returns from Cell B5, type: =CLEAN(B5).

Read More: Replace Carriage Return with Comma


Method 3 – Using VBA Code

We have some information in Cell B5 and B6 with carriage returns. We will replace the carriage returns with a comma followed by a space using VBA code.

Before and After using VBA

  • Go to the Developer tab >> select Visual Basic.
  • From the Visual Basic window, select Insert >> Module.
  • Paste the following code in the Module window:
Sub Delete_Carriage_Returns()
    Dim iRange As Range
    Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
        For Each iRange In ActiveSheet.UsedRange
                If 0 < InStr(iRange, Chr(10)) Then
                        iRange = Replace(iRange, Chr(10), ", ")
'the carriage returns will be replaced by a comma along with a space
                End If
        Next
    Application.ScreenUpdating = True
        Application.Calculation = xlCalculationAutomatic
End Sub

VBA code to remove carriage return in Excel

  • Select the range.
  • Go to Macros in the Developer tab.
  • From the Macro dialog box, select the code and click Run.

Steps to run VBA code

You will get results like the image below.

Result after using VBA for removing carriage return

Read More: Remove Carriage Returns in Excel


Tips for Using the Carriage Return in Excel

  • If the row height isn’t set to auto-adjust with the text, the cells with carriage returns will not display the whole text. Use the Wrap Text feature from the Home tab to display the whole text.

Use the Wrap Text feature

  • Add multiple carriage returns to increase readability.

double carriage return

  • When your formula gets relatively large, you might want to add carriage returns inside the formula. This helps users understand them better, but won’t affect the formula’s functionality.

carriage return in formulas


Things to Remember

  • By default, pressing Enter will take you to the cell below in Excel. Use Alt+Enter if you want to apply the carriage return directly in the Excel cell.
  • Use text wrapping if your cell values with carriage returns aren’t displaying fully.
  • The Find and Replace feature or the SUBSTITUTE function can replace carriage returns with one specific character at a time, and vice versa.
  • The TRIM function removes all the spaces from a text. Use with caution, as it can remove necessary spaces too.
  • When transferring or exporting data with carriage returns from Excel to other applications, some may treat them as different characters.

Frequently Asked Questions

How to add carriage return in Excel for multiple cells?

Use formulas and the Find and Replace features. Using the latter, you can also add them over the entire sheet.

How do I adjust the row height to display the entire text with carriage returns?

To adjust the rows to the texts, double-click below the row number on the left of the spreadsheet. It will automatically adjust to the number of lines created by carriage returns.

Can I export or print Excel data with carriage returns?

Yes, in some applications. However, some applications may have different character codes for the carriage return, so you have to consider the target file format and printer settings in such scenarios.


Download the Practice Workbook


Carriage Return in Excel: Knowledge Hub


<< Go Back to Text Formatting | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Abrar-ur-Rahman Niloy
Abrar-ur-Rahman Niloy

Abrar-ur-Rahman Niloy, holding a B.Sc. in Naval Architecture and Marine Engineering, has contributed to Exceldemy for nearly 1.5 years. As a leader in Excel, VBA, and Content Development teams, he authored 114+ articles and assisted the Exceldemy forum. Presently, as a project writer, he prioritizes stepping out of his comfort zone, aiming for constant technical improvement. Niloy's interests encompass Excel & VBA, Pivot Table, Power Query, Python, Data Analysis, and Machine Learning libraries, showcasing his commitment to diverse... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo