How to Fix Excel Leading Zeros Disappearing in Numbers and CSV Files

Typing a UK postal code, telephone number, employee badge ID, or inventory SKU into Microsoft Excel only to watch the initial zero vanish into thin air (turning 01234 into 1234) is an age-old headache. Similarly, opening a CSV export from your company database frequently strips leading zeros across entire columns without asking. Because Excel assumes any sequence of digits represents a mathematical quantity where leading zeros hold no mathematical value, it automatically truncates them. Fortunately, you can prevent this data loss using proper cell formatting, custom masks, and Power Query import controls.

Format Cells as Text Before Typing (Quickest Fix)

The simplest method to preserve leading zeros on new data entry is telling Excel to treat the cell contents as a literal text string rather than a numerical calculation.

  1. Select the column or cell range where you plan to enter your numbers.
  2. On the Home tab in the ribbon, locate the Number grouping.
  3. Click the drop-down menu currently displaying General.
  4. Scroll down to the bottom of the list and choose Text.
  5. Click into your formatted cells and type your numbers with leading zeros (e.g. 02079460000).

Excel will preserve every zero exactly as entered, aligning the text to the left side of the cell with a small green error indicator confirming text storage.

Use the Single Apostrophe Prefix Shortcut

If you only need to enter one or two numbers with leading zeros without altering the global formatting of an entire worksheet, an apostrophe provides an instant local override.

  1. Click the destination cell in Excel.
  2. Type a single straight apostrophe (') immediately before your digits (e.g. '0845123).
  3. Press Enter.

Excel displays the full number including the leading zero on your worksheet, whilst hiding the apostrophe in the background formula bar.

Apply a Custom Zero-Padded Number Format

If your values are fixed-length codes (such as five-digit postal codes or six-digit account numbers) and you still need Excel to treat them as numbers for sorting or calculations, a custom display mask is the ideal solution.

  1. Highlight the column containing your truncated numbers.
  2. Press Ctrl + 1 on your keyboard to open the Format Cells dialogue box.
  3. On the Number tab, select Custom at the bottom of the Category list.
  4. In the Type field on the right, delete whatever text is present.
  5. Type a sequence of zeros matching your required character length. For example, to ensure every number displays as five digits, type 00000.
  6. Click OK.

A value of 45 will now immediately display as 00045 on screen whilst remaining a pure number behind the scenes.

Import CSV Files via Power Query to Preserve Zeros

Double-clicking a CSV file opens it in Excel’s legacy auto-convert mode, which automatically wipes leading zeros upon launch. Importing the file properly preserves all data columns.

  1. Open a fresh, blank workbook in Excel.
  2. Switch to the Data tab in the ribbon.
  3. In the Get & Transform Data group, click From Text/CSV.
  4. Select your CSV file and click Import.
  5. In the preview window that appears, do not click Load. Instead, click Transform Data at the bottom.
  6. In the Power Query Editor, locate the column containing your leading zeros. Click the data type icon (showing 123) in the column header and change it to Text.
  7. Confirm the prompt by selecting Replace current step.
  8. Click Close & Load in the top-left corner.

Power Query imports your data into Excel with all original leading zeros intact without corrupting postal or account codes.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.