To keep a leading zero in Excel, the quickest fix is to type an apostrophe before the number ('01234). Excel then stores the entry as text and shows all the digits exactly as typed. For whole columns of codes, zip codes or phone numbers, the better long-term answer is to set the cell format to Text before typing, or to use the Custom format 00000 so numeric values still behave like numbers while displaying padded zeros. Either approach solves the core problem: Excel treats any entry beginning with zero as a number, drops the zero, and stores 1234 instead of 01234.
Below are the working methods, when to use each one, and how to recover entries that already lost their zeros. Menu labels can differ slightly by Excel version, platform and region, so the wording in your copy may be a little different from what is described here.
What You'll Need
- Excel on Windows, Mac, the web app, or the mobile app (the steps below assume the desktop version; mobile differences are noted)
- A spreadsheet with the cells you want to fix, or an empty one to test in
- For existing data: the original source of the codes, if the zeros are already gone
Step-by-Step
Method 1: Apostrophe for one-off entries
- Click the cell where the zero-prefixed value should go.
- Type an apostrophe first, then the digits: '01234.
- Press Enter. The apostrophe does not appear in the cell; only 01234 shows, aligned to the left like text.
- Check the formula bar: it shows the stored value as text. That confirms Excel kept the zero.
This is the fastest method for a handful of cells, but the entry is now text, so it will not add up, sort numerically or feed charts the way a number does. Use it for codes, not amounts.
Method 2: Format the column as Text before typing
- Select the column or the range of cells you will fill.
- Open the Format Cells dialog: press Ctrl+1 on Windows or Cmd+1 on Mac, or right-click and choose Format Cells.
- On the Number tab, choose Text in the Category list.
- Click OK, then type your values normally. Zeros stay in place.
Order matters here. Formatting as Text after the zeros are already gone does not bring them back, because the stored value is already 1234. Apply the format first, then type or paste.
Method 3: Custom format to keep numbers numeric
- Select the cells.
- Press Ctrl+1 (or Cmd+1 on Mac) to open Format Cells.
- Choose Custom at the bottom of the Category list.
- In the Type box, enter a zero for each digit you need. For five-digit codes use 00000; for a ten-digit phone number use 0000000000.
- Click OK. The cells still hold real numbers, but display with leading zeros.
This is the best option when you need the values to look padded but still sort as numbers and work in formulas. Remember that the format only affects display: if you export to CSV, the raw number goes without the zeros.
Method 4: Recover zeros in data you already entered
- If the original values exist elsewhere, such as a list or an export file, re-import them into cells that are already formatted as Text or 00000.
- If you must pad what is already in the sheet, use a helper column with the TEXT function: =TEXT(A2,"00000") for five digits.
- Copy the helper results, then paste them back over the original column using Paste Special > Values if you want to keep the text.
- Delete the helper column once the values look right.
Recovering lost zeros without the source list is guesswork: Excel has no way to know whether 1234 was once 01234, 001234 or 00001234. The digit count you choose has to come from your own record of the format.
Method 5: Stop Excel stripping zeros on import
- Open the file through Data > From Text/CSV rather than double-clicking it.
- In the preview window, set the column containing codes to Text instead of General or Whole Number.
- Choose Load. The zeros survive because Excel never converts those cells to numbers.
For CSV files you open directly, Excel applies its own guesses, which is why zip codes and product numbers lose their zeros. The import route gives you control over each column's type.
Common Mistakes
- Formatting after the fact. Setting Text or 00000 on cells that already lost their zeros only changes appearance or type; the zero is not restored.
- Using Text format for amounts. Currency and quantities should stay numeric, or totals and sorting break. Use the custom 00000 format instead.
- Trusting the display after export. A custom-formatted value exported to CSV or pasted into another app loses the padding, because the underlying number has no leading zeros.
- Pasting plain values into a Text-formatted column. A normal paste can convert text back to numbers. Use Paste Special > Values and check the result.
- Assuming the green triangle is an error. Excel flags text-that-looks-like-a-number with a small marker. For code columns this is expected; ignore it rather than converting to number.
Tips
- Set the format for the whole column, including many empty rows below, so future entries are covered without repeated work.
- Decide early whether a column is a code or a quantity. Codes belong in Text or a padded custom format; quantities belong in General or Number.
- Keep the apostrophe method for quick edits and the custom format for anything that must sort or calculate.
- When sharing a file, add a note above the column explaining that zeros are formatting, so nobody converts the cells to numbers later.
- In the mobile app the Format Cells options are limited; for precise custom formats, edit on desktop or the web app and reopen on the phone.
Troubleshooting
The zero still disappears. Check the cell's format with Ctrl+1. If it shows General or Number, the cell is converting your entry. Switch to Text or the 00000 custom format and retype the value.
I typed the apostrophe and it shows on screen. The leading character may not have been a straight apostrophe, or the cell is in edit mode. Delete the cell contents, retype with a plain ' character, and press Enter rather than clicking elsewhere.
The column now won't sum or sort correctly. That is the trade-off of Text format. If you need both padding and calculations, move to the 00000 custom format so the values remain numbers.
Zeros vanish again after pasting. Use Paste Special > Values into a pre-formatted range, or paste into Notepad first and back, which forces text. If the source is a CSV, use Data > From Text/CSV and set the column type to Text.
Numbers show with a small warning marker. This is Excel's text-stored-as-number check. Leave it for code columns, or use the custom format if the marker is distracting.
Nothing looks different after the change. Confirm you edited the right range; selecting a single cell and formatting it does not affect the rest of the column. Reapply to the full column and retype the affected entries.
If none of this holds, close and reopen the workbook, or copy the sheet into a fresh file. Rarely, a damaged file keeps snapping formats back, and a clean copy usually resolves it.
Frequently Asked Questions
Why does Excel remove the zero when I type it?
Because a leading zero has no mathematical value, Excel reads the entry as a number and drops it. Formatting the cell as Text, using an apostrophe, or applying a custom 00000 format prevents that.
Can I keep zeros without turning the cell into text?
Yes. A custom number format such as 00000 pads the display while the cell remains a true number, so it still sorts and calculates normally.
How do I get back a zero I already lost?
Only from the original source or by recreating the value with the format you know was used. Formatting alone cannot restore a digit Excel no longer stores, and the TEXT function can pad a number but has to be told the digit count.
Does the apostrophe method work on Mac and mobile?
Yes on Mac. On the mobile app, text formatting is limited, so entering a value that begins with an apostrophe or editing the file on desktop and syncing is the more reliable route.
Will the zeros stay when I save as CSV?
No. CSV stores only the underlying values, so a custom-formatted 01234 saves as 1234. Use Text format if the padded value must survive the export, or re-import with the column typed as Text.