ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to add leading 0 to four digit number? (https://www.excelbanter.com/excel-worksheet-functions/8495-how-add-leading-0-four-digit-number.html)

Calendar Control

How to add leading 0 to four digit number?
 
I have a column of Zip codes in an Excel spreadsheet. Some of the values are
4 digits in length and some are 5 digits in length. I need to have the
column in text format, but since the format was numeric the leading zero
disappears. I need a formula that determines that if the length of the value
is 4 characters than add a leading zero.

Peo Sjoblom

One way

=TEXT(A1,"00000")

Regards,

Peo Sjoblom

"Calendar Control" wrote:

I have a column of Zip codes in an Excel spreadsheet. Some of the values are
4 digits in length and some are 5 digits in length. I need to have the
column in text format, but since the format was numeric the leading zero
disappears. I need a formula that determines that if the length of the value
is 4 characters than add a leading zero.


Arvi Laanemets

Hi

With numeric code in cell A2
=TEXT(A2,"00000")
With variable length numeric string as code in cell A2
=TEXT(VALUE(A2),"00000")

Arvi Laanemets


"Calendar Control" wrote in
message ...
I have a column of Zip codes in an Excel spreadsheet. Some of the values

are
4 digits in length and some are 5 digits in length. I need to have the
column in text format, but since the format was numeric the leading zero
disappears. I need a formula that determines that if the length of the

value
is 4 characters than add a leading zero.





All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com