Excel Formula for New Line in Cell
In this article
Yes, you can force a new line within a single cell in Excel using the CHAR(10) function combined with the TEXTJOIN function, or the CONCAT function. This technique allows you to display multiple lines of data within a single spreadsheet cell, which is useful for creating formatted lists, addresses, or notes without needing to merge multiple cells or use multiple rows.
What You'll Need
- A modern version of Microsoft Excel (Excel 2016 or later is recommended for the best results with TEXTJOIN).
- The data you wish to format into multiple lines.
- A basic understanding of Excel formulas.
Step-by-Step
- Prepare your data. Ensure the text you want to format is located in a single column or cell. For this guide, we will assume you have a list of items in column A (rows 1 through 5) that you want to separate into individual lines within a single cell. Imagine the data looks like this:
- A1: Item One
- A2: Item Two
- A3: Item Three
- A4: Item Four
- A5: Item Five
- Identify the formula syntax. The two primary methods to achieve this are using the TEXTJOIN function or the CONCAT function. Both require the CHAR(10) function to generate the line break character.
- Method 1: Using TEXTJOIN (Recommended). This method is the most robust for combining a range of cells into one string with a separator.
- Click on the cell where you want the final multi-line text to appear (e.g., cell B1).
- Type the following formula into the cell:
=TEXTJOIN(CHAR(10), TRUE, A1:A5)
- Press Enter on your keyboard.
- Observe the result. The text should now appear on multiple lines within the single cell.
- Format the cell to display the lines. By default, Excel might still display the text as a single line even though the formula contains the line break code. To make the lines visible:
- Right-click the cell (B1) containing the formula.
- Select Format Cells from the context menu.
- In the Format Cells dialog box, go to the Alignment tab.
- Check the box that says Wrap text.
- Click OK.
- Method 2: Using CONCAT (Legacy/Single Cell). This method is useful if you are not combining a range but simply want to add a line break between two specific pieces of text in one cell, or if you are on an older version of Excel that does not support TEXTJOIN.
- Click on the cell where you want the result to appear (e.g., cell C1).
- Type the following formula:
="Line 1 text" & CHAR(10) & "Line 2 text"
- Press Enter.
- Repeat the Format Cells > Alignment > Wrap text steps from Method 1 to see the new lines.
- Using the Ampersand (&) operator with ranges. If you are using the older CONCAT function and want to combine a range of cells with line breaks, the syntax is slightly different. You must use the TRANSPOSE function to turn the range into an array that CONCAT can process.
- In a blank cell, type the following formula:
=CONCAT(TRANSPOSE(A1:A5 & CHAR(10)))
- Press Enter. Note that you may need to press Ctrl + Shift + Enter instead of just Enter, depending on your specific Excel configuration and version, to turn this into an array formula.
- Again, apply Wrap text formatting to the cell to view the result.
- In a blank cell, type the following formula:
Common Mistakes
- Forgetting Wrap Text. The most common mistake is entering the formula correctly but not formatting the cell to wrap text. Excel stores the line break internally (the CHAR(10) code), but visually displays it as one long line until you enable the Wrap Text option in the Alignment tab. If the text is shorter than the cell width, it might look correct, but if the text is longer, it will overflow the cell boundaries without wrapping.
- Using the wrong separator. When using TEXTJOIN, the first argument is the separator. If you put a comma or space there by mistake, you will get a list like "Item One, Item Two, Item Three" instead of a list where each item is on a new line. Ensure the separator is CHAR(10).
- Using CHAR(10) in older formulas. If you are manually typing a formula to join text without TEXTJOIN, simply typing CHAR(10) into the middle of the string might not work as expected if the Excel settings for the formula engine do not interpret it correctly in that specific context, necessitating the use of the ampersand (&) operator to concatenate it properly.
Tips
- Use TEXTJOIN for ranges. Always prefer the TEXTJOIN function when combining multiple cells. It is much simpler and more reliable than the old CONCAT function combined with TRANSPOSE, especially for beginners. It allows you to easily change the separator by just editing the first part of the formula.
- Copy and Paste as Values. Once you have created your multi-line text and it looks exactly how you want it, you might want to remove the formula so you cannot accidentally break it later. Select the cell, copy it, then right-click another cell and choose Paste Special > Values. This will permanently paste the text into the cell, removing the underlying formula.
- Handling Carriage Returns in Data Sources. Sometimes the data you are trying to format already contains line breaks (e.g., an exported report). If you use TEXTJOIN on this data, you might end up with double line breaks. To clean this, you can use the SUBSTITUTE function to remove existing line breaks before joining them, or simply edit the source data directly.
- Adjusting Vertical Alignment. While Wrap text is the standard way to handle multi-line text, you can also adjust vertical alignment. If you place multi-line text in a very tall cell, you can choose Top alignment in the Format Cells dialog to push the text to the top of the cell, or Justify (which acts like a text box) to distribute the lines evenly.
Troubleshooting
If the formula does not produce the desired result, follow these steps in order:
- Check Cell Formatting (Wrap Text). As noted in the Common Mistakes section, the most frequent cause of failure is that the cell is not formatted to wrap text. Go to the cell, right-click, select Format Cells, and ensure the Wrap text box is checked. This is the first thing to verify.
- Verify the Formula Syntax. If you are using TEXTJOIN, ensure the syntax is
=TEXTJOIN(CHAR(10), TRUE, range). If you are using CONCAT, ensure you are using the ampersand operator to join the CHAR(10) to the text string, not just placing it in the middle of parentheses. - Check for Hidden Characters. Sometimes, data copied from the web or other applications can contain invisible special characters that break formulas. If the formula returns an error, check if the data source cells contain non-standard characters. If so, clear the data and re-type it manually.
- Excel Version Compatibility. If you are on an older version of Excel (older than 2016) and trying to use TEXTJOIN, it will not exist. You must use the CONCAT function with the TRANSPOSE trick described in the steps. If you are on a very new version (365), ensure your Excel is up to date to avoid any quirks in the formula parser.
- Viewing the Line Break. If the text appears to have disappeared or is showing as ######, it may be because the cell is too narrow to display the wrapped text. Increase the width of the column containing the formula until the text becomes visible.
Frequently Asked Questions
Can I use this method to print multiple lines on one page?
Yes. When you print a worksheet containing cells with text wrapped using CHAR(10), Excel will automatically print the text across the page width, respecting the line breaks defined in the cell.
Why does CHAR(10) work and CHAR(13) not?
CHAR(10) represents the line feed character, which is the standard for line breaks in Windows applications like Excel. CHAR(13) represents the carriage return, which often just moves the cursor to the beginning of the same line in Excel rather than starting a new one.
Does this work in Google Sheets?
Yes, the CHAR(10) method works in Google Sheets as well. However, the formula syntax is slightly different; you must use the JOIN function instead of TEXTJOIN, and the separator must be the line break character, typically entered as CHAR(10) or using the literal string "
".
Can I sort data that has line breaks in cells?
Yes, Excel can sort data where cells contain line breaks. The sort function will treat the entire contents of the cell as a single string for comparison purposes. This is useful for sorting lists of addresses or items that are formatted internally.
How do I remove line breaks from a cell?
You can remove line breaks using the SUBSTITUTE function. The formula =SUBSTITUTE(A1, CHAR(10), "") will replace every line break character in cell A1 with an empty string, effectively removing the new lines and joining the text together.