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:
=Left(G3, 5)
Figure 1. The Paste Special dialog box.
If you have an empty column to the right of your ZIP Codes, you can also use Excel's Text to Columns feature:
Figure 2. The Convert Text to Columns Wizard.
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:
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.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
Sometimes you receive a phone number that contains alphabetic characters and you need to convert it to a purely numeric ...
Discover MoreIf you import information generated on a UNIX system, you may need to figure out how to change the date/time stamps to ...
Discover MoreDifferent industries and different computer systems specify dates in all sorts of strange ways. If you need to convert a ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2017-04-02 02:24:59
@ 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
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments