How to Keep 0 in an Excel Sheet: Leading Zeros and Zero Values
Stop Excel from dropping the 0 in front of numbers or hiding zero values. Learn the Text format, apostrophe, custom formats, TEXT, and the show-zero setting.
To keep a 0 at the start of a number in Excel (like 00123 or a ZIP code), format the cells as Text before you type, or type an apostrophe first (‘00123). If instead your cells show blanks where a 0 should be, turn the zero display back on: on Windows go to File > Options > Advanced and check Show a zero in cells that have zero value.
Those two problems look similar but have different causes, so it helps to know which one you have. The rest of this guide covers both, plus imports, formulas and long ID numbers. Steps are based on Microsoft’s documentation as of November 2026; menu names can shift between Excel versions.
Which “missing 0” problem do you have?
| What you see | What’s happening | Quickest fix |
|---|---|---|
| You type 0123 and Excel shows 123 | Excel converts the entry to a number and drops leading zeros | Text format, apostrophe, or custom format |
| A CSV import loses zeros in ZIP codes or IDs | Excel converts the column to numbers on import | Import via Get Data and set the column to Text, or change Automatic Data Conversion |
| A formula that equals 0 shows an empty cell | Zero display is turned off, or a number format hides zeros | Turn on “show a zero” or reset the format to General |
| A 16-digit number ends in 0 | Excel keeps only 15 significant digits | Store the value as text |
Keeping leading zeros when you type
Microsoft’s Keeping leading zeros and large numbers article describes the main options. Pick based on whether the value needs to behave like a number.
Option 1: Format the cells as Text (best for IDs and codes)
Use this for ZIP codes, employee IDs, product codes and phone numbers, anything you’ll never add up.
- Select the cells or the whole column.
- Press Ctrl+1 (Cmd+1 on Mac) to open Format Cells, or use the number format drop-down on the Home tab.
- Choose Text and click OK.
- Type your values. Excel now stores exactly what you type, zeros included.
Order matters: apply the format before entering the data. Changing an existing number to Text doesn’t put back a zero that’s already been stripped, so you’ll need to re-type or re-import those entries.
Option 2: Type an apostrophe first
For a quick one-off, type an apostrophe before the number, for example '00123. The apostrophe doesn’t show in the cell, and Excel stores the entry as text. Excel may flag the cell with a small green triangle warning that it’s a number stored as text. That’s expected, and you can ignore it for codes.
Option 3: Use a custom number format (when it must stay a number)
If the value needs to stay numeric, for sorting numerically or using in calculations, use a custom format that pads the display with zeros:
- Select the cells and press Ctrl+1.
- Choose Custom.
- In the Type box, enter one 0 per digit you want, for example
00000for five-digit codes. - Click OK.
Now 123 displays as 00123. The catch is that the zeros exist only on screen. The stored value is still 123, so exporting to CSV or matching against a text list may lose them. Microsoft notes that this approach keeps leading zeros only within the workbook and works for codes with fewer than 16 digits. Excel’s Special category also has preset formats such as ZIP Code that work the same way.
Option 4: Build a text version with the TEXT function
When you need the zeros to be part of the actual value, for example in a helper column for an export or a lookup, convert with a formula:
=TEXT(A2,"00000")
The result is text padded to five characters. Keep the format code inside quotation marks, because =TEXT(A2,00000) won’t work. Once the result looks right, you can copy the column and use Paste Special > Values to replace the formulas with static text.
Stopping Excel from removing zeros automatically
Newer versions of Excel let you switch off the conversion that strips leading zeros. Microsoft introduced these controls for Windows and Mac (see the Microsoft 365 Insider announcement), and the Set automatic data conversions page documents them.
- Windows: go to File > Options > Data and find Automatic Data Conversion. Mac: go to Excel > Preferences > Edit > Automatic Data Conversion.
- Clear the option to remove leading zeros from numerical text and convert it to a number.
- Click OK.
With that box cleared, Excel stores entries like 00123 as text and keeps the zeros. Two caveats:
- The original Insider post listed the path as File > Options > Advanced, while current Microsoft help points to the Data tab. If you don’t see it in one place, check the other. Older, non-subscription versions of Excel may not have the setting at all.
- Some users on Microsoft’s community forums report that CSV files still lose zeros after they change these settings. If that happens to you, import the file with the steps below.
Keeping zeros when importing CSV or text files
Double-clicking a CSV opens it with default conversions, which is where many ZIP codes lose their zeros. A more reliable route is to import:
- Open a blank workbook and go to Data > Get Data > From File > From Text/CSV (labels vary slightly by version).
- Select the file, then choose Transform Data to open Power Query.
- Click the header of each column that needs zeros, and set its data type to Text.
- Choose Close & Load.
If you use the legacy Text Import Wizard instead, select the affected column in the last step and set its format to Text. Either way, the column comes in as text and keeps every digit.
Long numbers: the 15-digit limit
Excel keeps a maximum of 15 significant digits in a number. According to Microsoft, any digits after the 15th in a longer number, such as a 16-digit card number, are changed to zero. No number format can fix that, because the digits are gone once the value is stored.
To keep long identifiers intact, format the column as Text before entering or importing them, or use the apostrophe prefix. Treat them as labels, not numbers, which they are.
When zero values show as blank cells
If your problem is a formula result or entered 0 that displays as nothing, something is hiding zeros. Microsoft’s Display or hide zero values page covers the causes.
Turn the worksheet setting back on
Windows:
- Go to File > Options > Advanced.
- Under Display options for this worksheet, pick the sheet.
- Check Show a zero in cells that have zero value, then click OK.
Mac (Microsoft’s Mac instructions): go to Excel > Preferences > View, and under Window options check Show zero values.
This setting applies per worksheet, so check each sheet that’s affected.
Check for a zero-hiding number format
Custom formats have up to four sections separated by semicolons: positive; negative; zero; text. If the third section is empty, as in 0;-0;;@, zeros display as blanks. MrExcel’s custom number formatting tips explain how that empty section suppresses zeros.
To fix it, select the cells, press Ctrl+1, and choose General (or Number). You can also edit the custom code so the third section contains a 0.
Check the formula
Some workbooks use formulas such as =IF(A1=0,"",A1) to return a blank instead of 0. If that’s in play, edit the formula to return the value directly. A blank text result can also trip up later calculations, so it’s worth removing if you actually want zeros shown.
A note for browser users: Microsoft says the hide-zeros setting can’t be changed in Excel for the web, so if a file hides zeros, you may need to open it in the desktop app to turn them back on.
Which method should you use?
- IDs, codes, ZIP and phone numbers: format as Text before entering or importing.
- One or two quick entries: use an apostrophe.
- Numbers that must stay numeric but look padded: use a custom format like
00000. - Exports and lookups: create a text column with
TEXT(). - Blank cells instead of 0: turn on “show a zero” and reset any custom format.
Get the format right before the data goes in and most “disappearing 0” problems never happen.
Free apps worth trying
SponsoredSponsored links. Installing through them can earn us a commission, at no cost to you. Apps are free to download; some offer optional in-app purchases.
Frequently asked questions
Why does Excel remove the 0 at the start of my number? +
Excel treats an entry like 01234 as the number 1234, and numbers have no leading zeros. To keep the zero, store the entry as text (Text format or an apostrophe) or apply a custom number format such as 00000.
Will a custom format like 00000 bring back zeros that are already gone? +
It will display numbers padded to the length you set, but it does not change the stored value, and it cannot recover digits that were lost for other reasons. If the original codes had varying lengths, re-enter or re-import them as text instead.
Why are my zero values showing as blank cells? +
Either the worksheet option to show a zero in cells that have zero value is turned off, or the cells use a custom format with an empty zero section, such as 0;-0;;@. Turn the option back on in Excel's settings, or reset the cells to the General format.
How do I keep long numbers like card or account numbers intact? +
Excel keeps only 15 significant digits for numbers, so digits after the 15th become zeros. Format the column as Text before you type or import the values, or prefix each with an apostrophe.
Sources
- Keeping leading zeros and large numbers (Microsoft Support) (support.microsoft.com)
- Display or hide zero values (Microsoft Support) (support.microsoft.com)
- Display or hide zero values in Excel for Mac (Microsoft Support) (support.microsoft.com)
- Set automatic data conversions (Microsoft Support) (support.microsoft.com)
- Control data conversions in Excel for Windows and Mac (Microsoft 365 Insider blog) (insider.microsoft365.com)
- Hide Zeros & Other Custom Number Formatting Tricks (MrExcel) (mrexcel.com)