How to Format a Zip Code in Microsoft Excel

Excel Image Header

When entering numbers into Microsoft Excel, leading zeros are removed by default. This can be problematic for ZIP codes, phone numbers, credit/debit card numbers and IDs that you type into a cell. We are going to explore some options on fixing this Excel behavior.

If you want to keep a leading zero on the fly, you can enter an apostrophe (‘) before you enter the number that begins with zero. Excel treats the number as a text field. The apostrophe (‘) is not displayed and calculations will still work. But who wants to do this every time, there has to be a better way.

This is for Excel for Office 365 Windows and Mac versions. Other versions of Excel will be similar.

Create the Excel Sheet

Create a simple Excel sheet like the example below:

Zip Code Format 1
Excel Sheet for Zip Codes

Setup the Zip Code Format

  • Select a cell or range of cells to format; in my case G2 thru G6
  • Click “Ctrl+1” to load Format Cells dialog. Also, you can right click and select Format Cells.
  • Select the Number tab
  • Select Custom from the Category list
  • In the Type box, type in 00000 for a five digit zip code or 00000-0000 for a nine digit zip code. This allows leading zeros to be placed in the cell, you only have to enter the Zip code numbers. This is not intuitive, you think you have to select a format from the list. Refer to the following image:
Zip Code Format 3
Setup Excel Sheet format

Using the Special Zip Code Format

You can also click Special, then select Zip Code or Zip Code + 4. In Google Sheets, this special Zip code format is not available, but you can enter the format of leading zeros. See the following example:

Zip Code Format 2
Excel Special Zip Code format
  • Click OK to apply the format. The 00000 or 00000-0000 format is saved in the Type list for future use.

This will only effect Zip Codes that are entered after the format is applied.

You can also format the Zip Code as Plain Text. Anything you enter will show exactly how you typed it in text.

To do this:

  • Select your data range
  • Press “Ctrl+1” to launch the Format Cells dialog box
  • On the Number tab, click Text

What about Zip Codes entries that have more than 5 digits? We can use a Conditional Format in an adjacent column to flag the invalid Zip codes. I used the formula; if the length (cell reference)>5 is True then present an “Invalid Zip” message, if the expression is False, then no message is presented.

Flagging Invalid Zip Codes

  • Create a column adjacent to the Zip Code and label it Error Message
  • Set the Conditional Format for the first cell adjacent to the Zip Code. In my example, it is cell G2
  • Type in this formula, =IF (LEN(your cell reference)>5,”Invalid Zip”,””)
  • Copy this formula, then highlight a range of cells, then Paste

See the following image for the Invalid Zip message related to cell G2 and G6, both have more than 5 numbers. An important note, Excel lets you enter as many digits as allowed, there is no truncation. The template of 00000 formatting is for adding leading zeros if the number of digits is less than 5.

Zip Code Format 5
Flagging Invalid Zip Codes screen

I Would Like to Hear from You

Please feel free to leave a comment. I would love hearing from you. Do you have a computer or smart device tech question? I will do my best to answer your inquiry. Please mention the device, app and version that you are using. To help us out, you can send screenshots of your data related to your question.

The author’s Vietnam eBook on the Battle for Tra Bong: Events and Aftermath


Author: Raymond

I am Raymond Oglesby, an Information Technology (IT) specialist with 30 years in the field. I have taught Microsoft Applications and troubleshot computers in 15 countries and many States. My career was focused on mainframes and desktops from application development to implementation. I have written hundreds of programs for various architectures. I decided to start a blog to share my knowledge and experiences with you. I plan on updating this blog at least twice a week about smart phone apps to Windows. Please feel free to leave a Comment or Tweet. I would love to hear from you. Do you have a computer tech question? I will do my best to answer your inquiry. Please mention the app and version that you are using. To help me out, you can send screenshots of your data related to your question.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: