Excel removes leading zeros when pasting data

christana davell 0 Reputation points
2026-11-28T17:45:30.8+00:00

I have a column formatted with a custom number format (00000), but whenever I paste product codes from another workbook, the leading zeros disappear. Is there a way to preserve the formatting when pasting values?

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

2 answers

Sort by: Most helpful
  1. Aetherin 5,000 Reputation points Independent Advisor
    2026-11-28T18:20:50.59+00:00

    Hi @christana davell,

    A regular paste can overwrite the destination cell formatting with the formatting from the source workbook. To keep the existing 00000 custom format, try:

    • Copy the product codes.
    • In the destination column, right-click the first cell.
    • Select Paste Special > Values.

    This pastes the underlying values without replacing the destination column’s custom number format. For example, a value of 123 should continue to display as 00123.

    User's image

    If the leading zeros are part of the actual product code rather than just its display, format the destination column as Text before pasting. Product codes are generally better stored as text because they are identifiers, not numbers used in calculations. Microsoft also notes that formatting cells afterward does not restore zeros that Excel has already removed.

    You can find more information here: Keeping leading zeros and large numbers

    If I misunderstood your question or if the suggested solution doesn't work, could you please share a sample of your data? I'll take a closer look and provide further assistance.

    I look forward to your response.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. AI answer

    2026-11-28T17:45:44.17+00:00

    Yes. A custom number format like 00000 only changes how the value is displayed. If pasted product codes are treated as numbers, Excel can still drop the leading zeros in the underlying value.

    Use one of these approaches:

    1. Best option for future pastes: format the destination cells as Text before pasting
      • Select the target column.
      • On the Home tab, open the Number Format list.
      • Select Text.
      • Paste the product codes.
      This preserves the leading zeros exactly as pasted.
    2. If the values were already pasted and zeros were removed
      • A custom format will not restore zeros that were already stripped.
      • Use the TEXT function in a helper column, for example: =TEXT(A2,"00000")
      • Fill down, then copy the results and Paste Values if needed.
    3. If the codes can be longer than 15 digits
      • They must be stored as Text. Excel has a maximum of 15 digits of precision and rounds digits after that.

    A custom format such as 00000 works only for values entered after the format is applied, and only for number codes with fewer than 16 digits. For pasted product codes that must keep leading zeros reliably, Text format is the correct choice.


    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.