Sub topic 11
Multiple lines inside one cell
This chapter assumes you can select a cell, type an entry, and commit it with Enter. It also assumes you know how edit mode works (F2 or double-click). Here you will learn how to put more than one line of text in a single cell, and why the result sometimes looks wrong.
Why Enter does not start a new line
In normal entry, Enter commits the cell and moves the active cell down. To start a new line inside the cell instead, you insert a line break. A line break is a special character stored in the text that tells Excel to continue on the next line.
On Windows, press Alt+Enter while typing or editing. On Mac, press Control+Option+Return (some versions also accept Option+Return).
For example, select a cell, type Ada Lovelace, press Alt+Enter, type 12 Main Street, press Alt+Enter, type London, and press Enter to commit.
Wrap Text and row height
Alt+Enter turns on Wrap Text for the cell automatically. Wrap Text is a format that displays text on several lines when it does not fit the cell width. If the line break shows up as a single line, Wrap Text is off. Turn it on from Home, Alignment, Wrap Text.
Row height usually adjusts to fit the lines. If you set the row height by hand earlier, Excel keeps that height. Extra lines are then cut off from view, but they are still stored. Double-click the bottom border of the row header to auto-fit the height again.
The formula bar shows the cell's lines too. If the bar looks like it has only one line, expand it with the arrow at its right end or with Ctrl+Shift+U.
Line breaks in formulas
A line break is the character with code 10. You can add it to a formula with CHAR(10):
=A2&CHAR(10)&B2&CHAR(10)&C2This joins the values in A2, B2, and C2 with a line break between each. The result only appears on separate lines if Wrap Text is on for the formula cell. Unlike typing with Alt+Enter, a formula does not turn Wrap Text on for you.
Removing or replacing line breaks
Find and Replace can work with line breaks:
- Select the cells and press Ctrl+H.
- Click in the Find what box and press Ctrl+J. The box looks empty, but it now holds a line break.
- In Replace with, type a single space, or a comma and a space.
- Click Replace All.
Ctrl+J is how you type a line feed into a dialog box. It does not show anything on screen, so clear the box before your next search or the old break will still be there.
In a formula, SUBSTITUTE does the same job:
=SUBSTITUTE(A2,CHAR(10),", ")Common problems
| Symptom | Cause | Fix |
|---|---|---|
| Enter moved to the next cell | You pressed Enter, not Alt+Enter | Press F2 to edit, place the cursor, press Alt+Enter |
| Text runs on one line | Wrap Text is off | Turn on Wrap Text |
| Only the first line shows | Row height was set manually | Auto-fit the row |
| Formula result is one line | `CHAR(10)` used but Wrap Text is off | Turn on Wrap Text for that cell |
Exercise
Cell A2 contains Red and Blue on two lines. You want a single-line version in B2 that reads Red, Blue. Which formula does this, and why does it work?
Show answer
=SUBSTITUTE(A2,CHAR(10),", "). A line break is character 10. SUBSTITUTE replaces every occurrence of that character with a comma and a space, so the two lines become one.
Exercise
You type three lines into a cell with Alt+Enter, but only the first line is visible. The Wrap Text button is on. What is the most likely cause, and how do you fix it?
Show answer
The row height was set manually, so it does not grow to fit the lines. Double-click the bottom border of the row header to auto-fit the row.