Excel keeps dropping the leading zero in my ZIP Codes

 

How to keep leading zeros in number codes

Do you ever use things like social security numbers, phone numbers, credit card numbers, product codes, or postal codes in your workbooks? These are all examples of number codes, things that look like numbers, but that aren't intended to be used in formulas.

When you import or paste numbers codes like these into your workbook, Excel interprets them as numbers and applies a general or number format to them. As a consequence, any leading zeros are removed from the number codes, which is often not what you want. In this article, you'll learn how to retain leading zeros in number codes.

In addition, if you are using credit card  numbers  or other number codes that contain 16 digits or more, you must use a text format instead of a number format. That's because Excel has a maximum of 15 digits of precision and will round any numbers that follow the 15th digit down to zero.

 

Why Excel removes leading zeros

 

Number codes get into your Excel workbook in many ways. You might simply type them in, or copy and paste them from another program. Or, you might open a text file, or import data from a data source, such as an Access database. In many cases, Excel converts these number codes to a general or a number format. The default behavior of those formats is to remove any leading zeros and, depending on the length of the number, use scientific notation. Excel treats a number code as just another number, but you know that it's a number  code  and that the leading zeros need to stay put.

You might not even see this happen if you are dealing with a long list of number codes. So it's important to be aware of the issue, especially when the data is used in databases or other programs. Although you can convert the number format to a text format, you may not want to convert numbers to text, especially if you have a large list of long numbers, because this can increase the size of your workbook.

 

Use a custom format to keep the leading zeros

 

If you want to resolve the issue just within the workbook because it's not used by other programs as a data source, you can use a custom or a special format to keep the leading zeros. This works for number codes that contain fewer than 16 digits,

In addition, you can separate some of the digits in your number codes with dashes by adding these dashes to the custom format. For example, to make a phone number more readable, you can add a dash between the international code, the country/region code, the area code, the prefix, and the last few numbers.

Procedure    

  1. Select the cell or range of cells that you want to format.
  1. On the Home tab, in the Number group, click the dialog box launcher next to Number.
  1. In the Category list, click Custom and then, in the Type box, type the number format, (enter 5 zeroes) 00000 for a five-digit postal code.

 TIP   You can also click Special, and then select Zip Code, Zip Code + 4, 

 

Find more information about custom codes, see Create or delete a custom number format.

 

© 2005 - 2024 ProProfs
-
add chat to your website