How to Prevent 0 From Disappearing in Excel: Every Fix That Works
Stop Excel from dropping leading zeros or hiding zero values. Learn the Text format, apostrophe, custom formats, the data conversion setting and safe CSV imports.
To prevent a 0 from disappearing in Excel, tell Excel the value is text, not a number: format the cells as Text before you type, put an apostrophe in front of the entry ('00123), or, in Microsoft 365 and Excel 2024, turn off “Remove leading zeros from numerical text and convert to a number” under File > Options > Data. If your problem is that cells holding an actual zero look blank, the fix is different: re-enable “Show a zero in cells that have zero value” in File > Options > Advanced, or remove a custom format that hides zeros.
Below is which fix to use when, with the exact steps and the catches that trip people up. Menu names are as of November 2026 and Microsoft does move things occasionally.
Why Excel removes zeros in the first place
Excel’s default assumption is that anything that looks like a number is a number. According to Microsoft’s own support article, Excel automatically removes leading zeros, and converts large numbers to scientific notation such as 1.23E+15, so that formulas and math work on them. Mathematically, 00123 and 123 are the same value, so the zeros get dropped.
That’s fine for quantities, but bad for ZIP or postal codes, employee IDs, product SKUs, phone numbers and account numbers. Those are labels made of digits, and you never do math on them. The rule of thumb: if you’d never add it up, store it as text.
Quick comparison of the fixes
| Fix | Best for | Keeps value as a number? | Repairs already-lost zeros? |
|---|---|---|---|
| Format cells as Text first | IDs, codes, phone numbers you’ll type in | No (text) | No |
Apostrophe prefix ('0123) | One-off entries | No (text) | Only if you retype |
Custom number format (00000) | Fixed-length codes you still want as numbers | Yes | Yes, visually |
| Automatic Data Conversion setting | Stopping the behavior globally (Microsoft 365 / Excel 2024) | No (text) | No |
| Import CSV with column type Text | Data from other systems | No (text) | Yes, if the zeros are in the file |
TEXT() formula | Rebuilding codes from numbers | No (text result) | Yes |
Fix 1: Format the cells as Text before typing
This is the most dependable option for codes and IDs.
- Select the column or cells where the codes will go.
- Press Ctrl+1 (or right-click and choose Format Cells).
- On the Number tab, choose Text and select OK.
- Now type or paste your values.
00123stays00123.
The order matters. Microsoft notes that changing the format does not restore zeros that were removed before you applied it; it only affects values entered afterwards. If the zeros are already gone, use the custom format or TEXT() approach below.
Fix 2: Type an apostrophe first
Typing '00123 tells Excel to treat the entry as text. The apostrophe doesn’t show in the cell or print; you only see it in the formula bar. Excel may show a small green triangle warning about a “number stored as text.” That’s expected, and you can ignore it for codes.
This is handy for a single cell, but tedious for hundreds of rows. For bulk data, use Fix 1 or Fix 4.
Fix 3: Use a custom number format
If you need the value to stay a real number (say, for sorting numerically or lookups against a numeric column) but always display a fixed number of digits, use a custom format:
- Select the cells and press Ctrl+1.
- Choose Custom.
- In the Type box, enter one zero per digit you want, for example
00000for a five-digit postal code, then select OK.
123 will now display as 00123. Because this only changes the display, it also works on cells that already lost their zeros, as long as every code has the same length. Excel also offers a built-in Special category (for example, ZIP codes in US English) that does the same thing.
Microsoft points out a limit: custom formats work for number codes with fewer than 16 digits. For anything longer, see the section on long numbers below.
Fix 4: Turn off automatic leading-zero removal
Microsoft added an option to control this behavior, announced on the Microsoft 365 Insider blog. Per Microsoft’s Set automatic data conversions page, it’s available in Microsoft 365 and Excel 2024.
On Windows:
- Go to File > Options > Data.
- Under Automatic Data Conversion, clear Remove leading zeros from numerical text and convert to a number.
- Select OK.
On Mac: go to Excel > Preferences > Edit, and clear the same option under Automatic Data Conversion.
With the option off, Microsoft says numerical entries with leading zeros are stored as text and keep their zeros. The same section has related switches (for example, for long numbers and scientific notation) that are worth reviewing; Excel Campus has a walkthrough of each one.
Two caveats. Microsoft says this setting does not directly affect data imported with Power Query. And user reports on Microsoft’s Q&A forum are mixed: some say it fixed their problem, while others say zeros still vanished when opening a CSV file directly. Treat it as helpful, not foolproof, and use the import method below for CSVs.
Fix 5: Import CSV files instead of double-clicking them
Double-clicking a .csv opens it with Excel’s default conversions, and leading zeros disappear before you can do anything. Importing gives you control over each column’s type:
- Open a blank workbook and go to Data > Get Data > From File > From Text/CSV (or Data > From Text/CSV).
- Pick the file, then select Transform Data rather than Load.
- In the Power Query editor, right-click the column header with the codes and choose Change Type > Text.
- If asked, choose Replace current.
- Select Close & Load.
Check the column’s type in the preview before loading; Power Query guesses types automatically and may have already set it to a number in an earlier step. Replacing that step, rather than adding a new one after it, is what keeps the zeros.
Saving back to CSV is the reverse trap. A CSV only stores what’s in the cell. If you used a custom format (Fix 3), the underlying value is still 123, so that’s what gets written. For exports, convert the column to real text first (Fix 1 or Fix 6).
Fix 6: Rebuild lost zeros with the TEXT function
If a column already lost its zeros and every code should have the same length, a formula restores them as text:
=TEXT(A2,"00000")
This turns 123 into 00123. Fill it down, then copy the results and use Paste Special > Values to replace the originals if you no longer need the formula.
Long numbers: when the last digits turn into 0
A related problem: you paste a 16-digit card or account number and the final digit becomes 0. That isn’t a display issue. Microsoft’s troubleshooting article explains that Excel stores a maximum of 15 significant digits, so digits after the 15th are changed to zero.
No number format can fix this, because the digits are gone from the stored value. The only solution is to store such values as text from the start: format the cells as Text before entering, or prefix with an apostrophe. Reformatting afterwards won’t recover the lost digits, so re-enter or re-import them.
When zero values themselves don’t show
Sometimes “0 disappearing” means a cell that contains an actual zero, or a formula that returns zero, looks blank. Microsoft’s display-or-hide-zero-values guide lists the usual causes:
The worksheet option is turned off
- Go to File > Options > Advanced.
- Scroll to Display options for this worksheet and pick the sheet.
- Check Show a zero in cells that have zero value, then select OK.
This is a per-sheet setting, so a workbook from a colleague may have it off on one tab only. On a Mac, the equivalent is Excel > Preferences, then View (under Authoring), with the Zero values box checked. Microsoft notes that this option isn’t available in Excel for the web.
A custom format is hiding zeros
A format like 0;-0;;@ has an empty third section, which means “show nothing for zero.” Select the cells, press Ctrl+1, and set the category back to General (or another standard number format).
A formula is replacing zeros
Formulas such as =IF(A2-B2=0,"",A2-B2) deliberately return a blank for zero results. Edit the formula if you want the 0 to show.
The short version
For codes and IDs, set the column to Text before data goes in, and import CSVs rather than opening them. For fixed-length codes you still want as numbers, use a custom format like 00000. If actual zero values are vanishing, check the “Show a zero” option and any custom formats on those cells.
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
Will changing the format to Text bring back zeros Excel already removed? +
No. Microsoft notes that formatting only affects values entered after the format is applied. You have to retype the values, re-import them with the column set to Text, or rebuild them with a formula such as =TEXT(A2,"00000").
Why does the last digit of my 16-digit number turn into a 0? +
Excel stores numbers with a maximum of 15 significant digits, so anything past the 15th digit becomes zero. Credit card numbers and other long codes must be stored as text, either by formatting the cells as Text first or typing an apostrophe before the number.
Why do my zeros show up as blank cells instead of 0? +
Either the worksheet option "Show a zero in cells that have zero value" is turned off, or the cells use a custom number format with an empty zero section, such as 0;-0;;@. Turn the option back on in File > Options > Advanced, or reset the cells to the General format.
Does the Automatic Data Conversion setting fix CSV and Power Query imports? +
Microsoft says the setting does not directly affect data imported with Power Query, so set the column type to Text in the query instead. Some users also report mixed results when opening CSV files directly, so importing through Data > From Text/CSV is the more reliable route.
Sources
- Keeping leading zeros and large numbers (Microsoft Support) (support.microsoft.com)
- Set automatic data conversions (Microsoft Support) (support.microsoft.com)
- Display or hide zero values (Microsoft Support) (support.microsoft.com)
- Last digits are changed to zeros when you type long numbers in cells of Excel (Microsoft Learn) (learn.microsoft.com)
- Control data conversions in Excel for Windows and Mac (Microsoft 365 Insider Blog) (techcommunity.microsoft.com)
- New Excel Feature: Automatic Data Conversion for Numbers (Excel Campus) (excelcampus.com)