# How to pad text with spaces to a fixed length in Excel

Add plenty of spaces and cut back to the width: =LEFT(A2&REPT(" ",12),12) makes every value exactly 12 characters.

**Excel:** `=LEFT(A2&REPT(" ",$E$1),$E$1)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E |
| --- | --- | --- | --- | --- |
| Name | Padded |  | Width | 12 |
| Aiko |  |  |  |  |
| Ben Adams |  |  |  |  |
| Chidi Okafor |  |  |  |  |
| Dana |  |  |  |  |
| Maximilian Ortiz |  |  |  |  |

Formula in B2, filled to B6: `=LEFT(A2&REPT(" ",$E$1),$E$1)`

Result: Aiko        ; Ben Adams   ; Chidi Okafor; Dana        ; Maximilian O

## How it works

REPT adds as many spaces as the width, so there are always enough, and LEFT keeps exactly the width. Short names get trailing spaces and long names are cut, which is what fixed-width files for banks and older systems expect.

## Other ways

- `=RIGHT(REPT(" ",$E$1)&A2,$E$1)`: Pads on the left instead, which right-aligns the text; the usual layout for amounts in fixed-width files. (Spaces go in front: "        Aiko".)

## Common mistakes

- In a proportional font the padded values still look uneven. Check alignment in a fixed-width font like Courier New.
- TRIM, and many imports, strip the padding again. Pad as the last step before export.
- Names longer than the width are cut without warning. Flag them with `LEN(A2)>$E$1`.

## Questions

**How do I pad numbers with zeros instead?**

Use TEXT: `=TEXT(A2,"00000000")`.

**How do I pad with dots, like a table of contents?**

Repeat a dot instead: `=LEFT(A2&REPT(".",30),30)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/pad-text-to-a-fixed-length
