How to Add a Leading 0 in Excel (Keep It Visible)
In this article
Excel drops leading zeros because it treats anything that looks like a number as a number, and 007 is just 7 to a spreadsheet. To keep the zero visible, you either store the value as text or apply a number format that displays leading zeros without changing the underlying value. The quickest fix for a single cell or a short list is to type an apostrophe first: '007 and press Enter, and Excel stores it as text and shows 007. For a whole column of codes, phone numbers or ZIP codes, use Format Cells > Number > Custom with a format like 00000, or the Text format if you never want Excel to convert the value at all. The right choice depends on whether you need to do maths on the value or just display it. Labels can differ slightly between Excel versions, platforms and regions, but the options below are the standard ones on current desktop Excel for Windows and Mac.
What You'll Need
- Excel on Windows, Mac, or Excel for the web (the Format Cells dialog is available in all three; the ribbon layout varies slightly).
- The data you want to fix, or an empty column ready to receive it.
- A decision on whether the values are numbers (you will calculate with them) or identifiers (part numbers, ZIP codes, phone numbers, employee IDs). Identifiers should usually be stored as text.
Step-by-Step
- Decide the method first. If the value is an identifier that will never be summed or averaged, store it as text. If it is a real number that needs to display with padding, use a custom number format. Formatting is reversible and keeps the value numeric; text conversion is not reversible without retyping or a formula.
- Method 1 – the apostrophe (fastest, single cells). Click the cell, type an apostrophe, then the value: '007. Press Enter. Excel shows 007 and left-aligns it, which is your visual cue that it is text. The apostrophe itself is not displayed and does not appear in the formula bar as part of the value.
- Method 2 – format the column as Text before typing. Select the column or range, right-click and choose Format Cells, pick Text on the Number tab, and click OK. Now type 007 and it stays exactly as typed. This is the cleanest way to enter a long list of codes from scratch. Note that any values already in those cells are not converted retroactively — Text format only affects what you enter afterwards.
- Method 3 – custom number format (keeps the value numeric). Select the cells, press Ctrl+1 (Windows) or Cmd+1 (Mac) to open Format Cells, choose Custom at the bottom of the list, and type a format in the Type box. Use one zero for each digit you want to guarantee: 00000 turns 7 into 00007 and 1234 into 01234. Click OK. The value in the formula bar is still 7, so SUM and other functions work normally.
- Method 4 – the TEXT function (for formulas and imports). If the value comes from another cell or a calculation, wrap it: =TEXT(A2,"00000"). This produces a text string padded to five digits. Use it when you are building a combined label such as a product code, not when you need to keep calculating with the result.
- Method 5 – Power Query or Text Import for files that arrive stripped. If a CSV of ZIP codes opens with the zeros already gone, do not fix it after the fact. Re-open the file with Data > From Text/CSV, and in the import preview set that column's data type to Text before clicking Load. The zeros are preserved on the way in, which is the only reliable fix once they have been dropped.
- Check the result. Widen the column so nothing is hidden behind ###, and click a formatted cell to confirm the formula bar shows the value you expect. A custom-formatted 7 will show 00007 in the cell and 7 in the formula bar — that is correct, not an error.
Common Mistakes
- Formatting as Text after the fact. Changing a cell that already contains 7 to Text format leaves it as 7. You have to re-enter the value or use a formula such as =TEXT(A2,"00000").
- Using a custom format on text values. Number formats have no effect on text. If a cell already contains the text "007", applying 00000 changes nothing.
- Expecting maths to work on text. "007" stored as text will not add up in a SUM. If you need both display and calculation, use the custom number format instead.
- Leading zeros disappearing again after export. Saving to CSV strips formatting, so a custom-formatted 00007 becomes 7 in the file. For CSV exports, store the value as text or accept that the receiving system must re-pad it.
- Typing the apostrophe into an already-text cell. If the cell is formatted as Text, the apostrophe becomes part of the visible value. Only use it in cells that are in General format.
Tips
- Custom formats can mix padding with other characters: 000-00-0000 formats a nine-digit ID with dashes, and 00000 is the standard choice for five-digit ZIP codes.
- A custom format only pads up to the number of zeros you specify. A six-digit value in a 00000 format displays all six digits — the format sets a minimum width, not a maximum.
- To apply a format to a whole column quickly, click the column letter, then Ctrl+1. Be aware this also affects cells you add later in that column, which is usually what you want for an ID column.
- If you are pasting codes from another program, paste into a column already formatted as Text, or use Paste Special > Text where available, to stop Excel re-interpreting the values.
- Left-aligned values in a column of numbers is a quick visual check that they are stored as text.
Troubleshooting
The zeros still vanish when you type. The cell is in General or Number format. Either type the apostrophe first or set the column to Text before entering data.
The custom format does nothing. The cells probably contain text, not numbers. Look at the alignment and the formula bar; if the value is text, the number format is ignored.
The cell shows a row of hash marks (###). The column is too narrow for the formatted value. Drag the column border or double-click it to auto-fit.
Your totals stopped working after you padded the values. You converted numbers to text. Switch those cells back to a custom number format so the underlying value stays numeric.
The zeros come back after reopening the file. Check whether the file was saved as CSV. CSV keeps only the values, not the formatting, so the padding is lost on save. Keep the working file as .xlsx and export a CSV only as a copy.
Imported data lost its zeros before you saw it. Re-import with Data > From Text/CSV and set the column type to Text in the preview. Fixing it after import means re-entering the values or rebuilding them with TEXT.
Frequently Asked Questions
Why does Excel remove leading zeros?
Because it treats the entry as a number, and leading zeros have no value in a number. Formatting or text storage tells Excel to treat the entry as a label instead.
What is the fastest way to add a leading zero to one cell?
Type an apostrophe before the value, for example '007, and press Enter.
Does a custom number format change the actual value?
No. The cell displays 00007 but the stored value is still 7, so calculations continue to work.
Can I add leading zeros to a whole column at once?
Yes. Select the column, open Format Cells with Ctrl+1 or Cmd+1, choose Custom, and enter a format with the number of zeros you need.
Why do my leading zeros disappear when I save as CSV?
CSV stores values, not formatting. Store the column as text if the zeros must survive the export, or re-pad the data in whatever system reads the file.
How do I keep leading zeros in a ZIP code column?
Format the column as Text before typing, or apply the custom format 00000. Text is safer if the file will be exported or shared.