Retain zeros in a cell

Louise Wooding 0 Reputation points
2025-08-27T13:54:01.2866667+00:00

How do I enter a number but retain the zeros at the beginning? The numbers will all be different lengths - I thought of creating a custom number but can't get it to work. TIA

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HansV 462K Reputation points MVP Volunteer Moderator
    2025-08-27T14:25:16.0966667+00:00

    If these values are primarily identifiers, such as product numbers, you should store them as text instead of as numbers. You can do this by formatting the cells as Text before entering the values, or by prefixing the values with an apostrophe '. The apostrophe will be displayed in the formula bar but not in the cell itself.


  2. Sting-Ng 3,810 Reputation points Microsoft External Staff Moderator
    2025-08-28T00:11:31.3666667+00:00

    Hi @Louise Wooding

    Welcome to the Q&A Community 

    I’m here to assist with your problem. 

    To retain leading zeros when entering numbers of varying lengths in Excel (while storing them as text for VLOOKUP compatibility, without using an apostrophe), follow these steps: 

    • Select the cell(s) or range where you'll enter the data. 
    • Right-click and choose Format Cells (or press Ctrl+1 on Windows / Cmd+1 on Mac). 
    • In the Format Cells dialog, go to the Number tab. 
    • Under Category, select Text
    • Click OK

    User's image

    User's image

    Now, when you enter a value like 00123 into those cells, Excel will treat it as text and preserve the leading zeros exactly as typed. This works for any length, as it's not applying a fixed numeric format. 

    • For VLOOKUP: Ensure the lookup value and the table array column are both formatted as text for consistent matching. If needed, you can convert existing numeric data to text using the TEXT function (e.g., =TEXT(A1, "0")) or by selecting the range, going to Data > Text to Columns > Delimited > Next > Next > Text (under Column data format) > Finish. 
    • Noted: Once stored as text, arithmetic operations won't work directly on these values (e.g., summing them), but you can convert temporarily with VALUE() if needed (e.g., =VALUE(A1) + 10). 

    User's image

    We appreciate your kind patience and understanding that sometimes the initial response may not immediately resolve the issue or there may be some misunderstandings about your scenario, but we would love to hear updates from you and find out further suggestions. 

    Thank you for your kindness and understanding. If you need anything else, please feel free to contact me.  


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment" 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    User's image


Your answer

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