bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > Formulas > Data Conversion > Shortening ZIP Codes

Shortening ZIP Codes

Summary: US ZIP Codes can be of two varieties: five-digits or nine-digits. Here’s how to convert longer ZIP Codes to the shorter variety. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

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 (Click here to see a related figure.) by choosing Paste Special from the Edit menu. (In Excel 2007 display the Home tab of the ribbon, click the down-arrow under the Paste tool, and then click Paste Special.)
  5. Make sure the Values radio button is selected.
  6. Click on OK. Column H has now been transformed from formulas into the formula results.
  7. 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. (In Excel 2007 display the Data tab of the ribbon and click the Text to Columns tool in the Data group.) Excel displays the Convert Text to Columns Wizard. (Click here to see a related figure.)
  3. Make sure the Delimited option is selected, then click on Next.
  4. Select the Other check box, place a single dash in the box just to the right of Other, then click on Next.
  5. 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.)
  6. 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.

Tip #2654 applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007


Step Up and Take Control! Subscribers to ExcelTips know just how valuable a resource it is. ExcelTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on ExcelTips archives and e-books.
 
Check out ExcelTips Premium today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)