Excel deletes leading zeros because it treats any entry made of digits as a number, and numbers never keep zeros at the front. To stop it, either format the cells as Text before you type, or enter the value with a leading apostrophe (') so Excel stores it as text. For data you import or paste, use the Text Import Wizard or set the column format to Text first. The fix depends on whether you are typing new values, pasting existing ones, or importing a file.

What You'll Need

  • Excel for Windows, Mac, or the web version (steps are similar; labels can differ slightly by version and region).
  • The file or data containing the values with leading zeros.
  • Knowledge of whether the zeros must be kept for display only or for calculations (this affects which method you choose).

Step-by-Step

  1. Decide if the value is a number or an identifier. ZIP codes, phone numbers, employee IDs, and product codes are identifiers, not quantities. They should be stored as text. If you need to do math on the value, keep it as a number and use a custom format to display the zeros instead (see step 6).
  2. Format the column as Text before typing. Select the column or cells, right-click, choose Format Cells, pick Text, and click OK. Then type the value with the leading zero. Excel will keep it exactly as entered. This is the most reliable method for new data.
  3. Use the apostrophe trick for quick entries. Type an apostrophe before the number, for example '007. Excel stores it as text and hides the apostrophe in the cell. The formula bar will show the apostrophe. This works well for a few cells but is tedious for large datasets.
  4. Fix pasted data by pre-formatting the destination. If you paste values from another source, Excel may still convert them. Before pasting, format the destination cells as Text. Then use Paste Special > Values (or Paste Special > Text) instead of a normal paste. If the paste still drops zeros, paste into Notepad first, then copy from Notepad into the pre-formatted Excel cells.
  5. Use the Text Import Wizard for CSV and TXT files. Open the file via Data > From Text/CSV (or File > Open and choose the file). In the wizard, set the column containing the zeros to Text instead of General. Finish the import. This preserves leading zeros from the source file.
  6. Display leading zeros on real numbers with a custom format. If the cell must remain numeric, select it, open Format Cells, choose Custom, and enter a format code with the required number of zeros, such as 00000 for a five-digit code. The underlying value stays a number, but Excel displays the zeros. Note that this only works if the value has fewer digits than the format; a value of 123 in a 00000 format shows as 00123.
  7. Use a formula when you need to rebuild a text code. If zeros were already stripped, you can reconstruct the code with a formula such as =TEXT(A1,"00000") or =RIGHT("00000"&A1,5). Copy the result and paste as values if you need to replace the original column.
  8. Check your work. Click a fixed cell and look at the formula bar. If it shows the leading zero (or an apostrophe before it), the value is stored as text. If the formula bar shows a number without zeros, the cell is still numeric and will lose zeros on the next edit.

Common Mistakes

  • Formatting after typing. Changing a cell to Text after Excel has already converted the value to a number will not bring the zeros back. You must re-enter or re-import the data.
  • Using the apostrophe in formulas. The apostrophe is a text prefix, not part of the value. If you reference that cell in a formula, Excel treats it as text, which can break calculations.
  • Confusing display with storage. A custom number format shows zeros but does not change the stored value. If you export or copy the cell as a number, the zeros disappear again.
  • Pasting as normal instead of Paste Special. A regular paste can override your Text formatting. Always use Paste Special > Values when bringing in external data.
  • Ignoring the green triangle warning. Excel may flag text-formatted numbers with a green triangle. That is expected; do not click Convert to Number, or you will lose the zeros.

Tips

  • Set the entire column to Text before you start a new sheet for IDs or codes. It saves repeated fixes.
  • For CSV files you open often, use Data > From Text/CSV and save the query so the Text column setting is remembered.
  • If you only need the zeros for printing or display, a custom format is cleaner than converting everything to text.
  • When sharing a file, tell recipients not to convert text-formatted numbers back to numbers.
  • Use =TEXT(value,"format") when building codes in formulas, and paste the results as values before deleting the original column.

Troubleshooting

If the zeros still disappear after formatting as Text, check that you formatted the cells before entering the data. Re-enter one value to test. If pasting still strips zeros, paste into a plain text editor first, then copy from there into the pre-formatted cells. If a CSV import ignores your Text setting, make sure you are using the import wizard rather than double-clicking the file, which opens it with default settings. If a formula returns a number without zeros, wrap it in TEXT with the correct format code. If the file is shared and others see different results, confirm they are not converting text to numbers or using a different locale that interprets the data differently. For values that must remain numeric and also show zeros, use a custom format rather than text, and remember that calculations will use the underlying number, not the displayed zeros.

Frequently Asked Questions

Why does Excel remove leading zeros?

Excel treats digit-only entries as numbers, and numbers do not store leading zeros. Formatting the cell as Text or using an apostrophe prevents the conversion.

Can I keep leading zeros and still do math?

Yes, if you use a custom number format to display the zeros. The stored value remains a number, so formulas work, but the zeros are only for display.

Does the apostrophe method work on Excel for the web?

Yes, the apostrophe prefix works in Excel for the web and on Mac, though the exact behavior of some paste options can vary by version.

How do I stop Excel from removing zeros when I paste from another program?

Format the destination cells as Text first, then use Paste Special > Values. If that fails, paste into a text editor and copy from there.

Will converting text back to numbers lose my zeros?

Yes. Converting text-formatted numbers to numbers will strip leading zeros because the value becomes numeric. Avoid the Convert to Number option if zeros matter.

Can I set a default so new sheets keep zeros?

Excel does not have a global setting for this. The practical approach is to format columns as Text before entering data, or use a template with pre-formatted columns.