Search code examples
excelformatting

How to prevent automatic truncation of leading zeros in Excel cell


If I paste 04562, it automatically truncates the leading zero and stores it as 4562.

I want it to to store it as 04562.


Solution

  • If you are using MS Excel to edit the cells where you need to store the numbers with leading zero, just format and define the cell content as TEXT. If you are storing it programmatically, you can put the value in a quote '' for the same.

    Update

    I just noticed that if I go to "Format Cells" and select custom format and put, say 0000 to the format, any number that I put in the cell, it is is less than 4 digits, it still maintain the 4 digit length with the leading '0', like 0001, 0099, 0120, 9999