Excel guide · 5 min read
How to indent text in Excel
Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Line | Oct 2026 | Look up | |
| 2 | Revenue | 84200 | Rent | |
| 3 | Product sales | 61500 | ||
| 4 | Services | 22700 | ||
| 5 | Expenses | 57900 | ||
| 6 | Rent | 6500 | ||
| 7 | Salaries | 42800 | ||
| 8 | Software | 8600 |
Download this sheet as an Excel practice file (.xlsx)
Method 1: Increase Indent and Decrease Indent
This is the everyday way to show structure, like sub-accounts under a heading or tasks under a phase. The indent is formatting, so the cell still holds exactly what you typed.
- Select the cells to indent, for example the sub-items under each heading. Hold Ctrl to pick cells that aren't next to each other.
- Go to Home and find the Alignment group.
- Click Increase Indent (the icon with lines and an arrow pointing right). Each click adds one level.
- Click Decrease Indent to move back a level. At zero it does nothing.
- For a second level, such as accounts under a sub-heading, select those cells and click Increase Indent again.
Is there a keyboard shortcut?
Microsoft's list of Excel keyboard shortcuts has no dedicated indent shortcut, but on Windows you can use the ribbon keys: press Alt, then H for the Home tab, and Excel shows a letter or number on each button. Press the one shown on Increase Indent. The key tips are the same every time, so after a few uses it becomes muscle memory.
Method 2: an exact indent in Format Cells
When you need a specific depth, or the same depth on many columns, set it in the dialog. Microsoft's developer documentation describes the indent level as measured in characters, so each level is roughly one character wide in the cell's font.
- Select the cells and press Ctrl+1 (Cmd+1 on a Mac) to open Format Cells.
- Open the Alignment tab.
- Under Horizontal, choose Left (Indent). The Indent box becomes available.
- Type or pick the level, such as 2, and click OK.
Indenting numbers
Numbers sit on the right of the cell, and you usually want them to stay lined up on the right with a little room from the border. In Format Cells, choose Right (Indent) under Horizontal and set the Indent box: the numbers move in from the right edge and still line up on their decimal places.
If a number jumps to the left side of the cell when you click Increase Indent, the cell is set to a left indent. Open Format Cells and switch Horizontal to Right (Indent). Distributed (Indent) is the third option with an indent box; it spreads text across the width of the cell and is rarely what you want for a report.
Why typed spaces break your formulas
The sample P&L was indented the quick way: three spaces typed before each sub-item. It looks right, but the cell A6 now holds " Rent", seven characters, not "Rent". Look it up and Excel finds nothing. VLOOKUP returns #N/A, XLOOKUP returns its not-found value, COUNTIF(A2:A8,"Rent") counts 0, and a SUMIFS against an account list misses the row.
Sorting breaks too. A space sorts before letters, so a sort puts every spaced sub-item above Expenses and Revenue and the outline falls apart.
Result: Not found
Not found: no cell in A2:A8 is exactly "Rent"; the match is " Rent" with three leading spaces.
Can I make the lookup work without cleaning the data?
Yes. TRIM removes leading and trailing spaces, so look up in TRIM(A2:A8) instead. It works in Excel 365 and 2021 as written. Excel 2019 and earlier have no XLOOKUP; use =INDEX(B2:B8,MATCH(D2,TRIM(A2:A8),0)) entered with Ctrl+Shift+Enter.
Result: 6500
6,500: the lookup now compares "Rent" with the trimmed text.
Find and remove the spaces
To see whether a cell has hidden spaces, compare its length with the trimmed length. A6 has 7 characters but TRIM(A6) has 4, so three spaces are hiding in there. To count how many cells in a list start with a space, test the first character of each.
To clean the column, put =TRIM(A2) in a spare column, fill it down, copy it, paste it back over column A as values (Home > Paste > Paste Values), then apply a real indent with Increase Indent. If TRIM doesn't shorten a cell that clearly has a gap, it's probably a non-breaking space from a web page or PDF; replace it with =TRIM(SUBSTITUTE(A2,CHAR(160)," ")). More in remove spaces in Excel.
Result: 5
5: five of the seven lines start with a space.
How do I keep the outline levels when I remove the spaces?
Before trimming, add a Level column that records how deep each line was, for example =(LEN(A2)-LEN(TRIM(A2)))/3 when each level was three spaces. Use it to apply the indent and to total by level with SUMIFS.
Result: 3
3: the number of extra spaces in " Rent", one level of three spaces.
A second line inside a cell
Increase Indent indents every line of a wrapped cell equally. If you want only the second line pushed in, like a note under a heading in the same cell, press Alt+Enter (Control+Option+Return on a Mac) for a new line in the cell and type a few spaces before the second line. The same warning applies: those spaces are part of the text, so keep this for labels and notes, not for values you'll look up or sort.
Common mistakes
Indenting with the space bar
Spaces become part of the value and break lookups, COUNTIF and sorting. Use Increase Indent, which only changes the format.
Expecting TRIM to remove every gap
Non-breaking spaces (CHAR(160)) from web pages survive TRIM. Replace them with SUBSTITUTE first.
Losing the outline level when cleaning
Record each line's level in a helper column before you trim the spaces away.
Indenting numbers to the left
Choose Right (Indent) in Format Cells so numbers stay right-aligned and line up.
FAQ
How do I indent within a cell in Excel?
Select the cell and click Home > Increase Indent. For an exact amount, press Ctrl+1, choose Left (Indent) or Right (Indent) on the Alignment tab and set the Indent box.
Why can't I indent in Excel?
The Indent box in Format Cells only works with Left (Indent), Right (Indent) or Distributed (Indent) horizontal alignment. Switch the alignment first. If the buttons are greyed out, the sheet may be protected or you may still be typing in the cell; press Enter or Esc first.
Can I indent the second line of a cell only?
Not with the indent setting, which applies to every line. Start a new line with Alt+Enter and type spaces before it, keeping in mind the spaces become part of the text.
How do I remove an indent?
Click Decrease Indent until the text is back at the edge, or set the Indent box to 0 in Format Cells.
Functions used
XLOOKUPModern lookup in any directionTRIMRemoves extra spacesLENLength of textLEFTCharacters from the startSUMPRODUCTMultiply then addSUBSTITUTEReplaces textCHARCharacter from its code number
Related guides
- How to remove spaces in Excel (extra, all or hidden spaces)
- How to rotate text in Excel
- How to add bullet points in Excel
- Combine cells with a line break in Excel
- How to change the default font in Excel
- Excel formula returns 0 instead of the value: 7 causes and fixes
- Excel wrap text not working: 6 fixes
Updated