Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Shortening ZIP Codes.

# Shortening ZIP Codes

Written by Allen Wyatt (last updated January 7, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003

In the United States, ZIP Codes come in two formats: five-digit and nine-digit. (Actually, the five-digit ZIP Code is a subset of the nine-digit ZIP Code.) If you are an Excel worksheet that contains address information, you may want to convert nine-digit ZIP Codes to their five-digit equivalent.

This is a rather easy task to accomplish, since all you need to do is strip everything after the fifth digit in the ZIP Code. Follow these steps:

1. Insert a new column, just to the right of the existing ZIP Code column.
2. Assuming the ZIP Codes are in column G and you added a new column H, you can enter the following in cell H3:
```     =Left(G3, 5)
```
1. Copy this formula into all the appropriate cells of column H.
2. Select the entire column H.
3. Press Ctrl+C. Excel copies the entire column to the Clipboard.
4. Display the Paste Special dialog box by choosing Paste Special from the Edit menu. (See Figure 1.)
5. Figure 1. The Paste Special dialog box.

6. Make sure the Values radio button is selected.
7. Click on OK. Column H has now been transformed from formulas into the formula results.
8. Delete column G.

If you have an empty column to the right of your ZIP Codes, you can also use Excel's Text to Columns feature:

1. Select all the cells that contain your ZIP Codes.
2. From the Data menu, choose Text to Columns. (See Figure 2.)
3. Figure 2. The Convert Text to Columns Wizard.

4. Make sure the Delimited option is selected, then click on Next.
5. Select the Other check box, place a single dash in the box just to the right of Other, then click on Next.
6. In the Column Data Format area, select Text. (You want your ZIP Codes to be formatted as text so that you don't lose any leading zeros.)
7. Click on Finish.

At this point you have the first five digits of the ZIP Code in the original column, and the last four digits (if any) in the previously empty column to the right. You can delete the column containing the four digits, if desired.

If you need to truncate ZIP Codes quite often, you may be more interested in a macro-based approach. The following macro will do the trick:

```Sub ZIPShorter()
For Each cell In Selection
cell.Value = Left(cell.Value, 5)
Next
End Sub
```

All you need to do is select the cells containing the ZIP Codes, and then run the macro.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2654) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Shortening ZIP Codes.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Setting Line Spacing in the Equation Editor

The Equation Editor can be a great boon when you need to include complex mathematical equations in your document. The ...

Discover More

Formatting a Company Name

Want your company name to always appear in a particular formatted manner? Word provides two ways you can approach the ...

Discover More

Automatic Row Height for Wrapped Text

When you format a cell so that the information within it can wrap to multiple lines, you may be surprised if Excel ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

Pulling Apart Characters in a Long String

You can easily use formulas to pull apart text stored in a cell. For instance, if you need to pull individual characters ...

Discover More

Breaking Up Variable-Length Part Numbers

Part numbers can often be long, made up of other component elements. Breaking up part numbers into individual components ...

Discover More

Converting Phone Numbers

Sometimes you receive a phone number that contains alphabetic characters and you need to convert it to a purely numeric ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 7?

2017-04-02 02:24:59

Alan Elston

@ Willy
Yep using Evaluate to replace a loop is sometimes a great alternative
https://usefulgyaan.wordpress.com/2013/06/19/avoid-loop-for-range-calculations-evaluate/
Alan

2017-04-01 10:34:49

Willy Vanhaelen

You can replace the loop in the macro with only one line of code:

Sub ZIPShorter()
Selection = Evaluate("IF(Row(),LEFT(" & Selection.Address & ",5))")
End Sub

##### This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.