Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Shortening ZIP Codes.

Shortening ZIP Codes

Written by Allen Wyatt (last updated December 2, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


9

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 in 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 Home tab of the ribbon.
  5. Click the down-arrow under the Paste tool and choose Paste Special from the resulting choices. Excel displays the Paste Special dialog box. (See Figure 1.)
  6. Figure 1. The Paste Special dialog box.

  7. Make sure the Values radio button is selected.
  8. Click on OK. Column H has now been transformed from formulas into the formula results.
  9. 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. Display the Data tab of the ribbon.
  3. Click the Text to Columns tool, in the Data Tools group. Excel displays the first step of the Convert Text to Columns Wizard. (See Figure 2.)
  4. Figure 2. The first step of the Convert Text to Columns Wizard.

  5. Make sure the Delimited option is selected, then click on Next.
  6. Select the Other check box, place a single dash in the box just to the right of Other, then click on Next.
  7. 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.)
  8. 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 (10768) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel 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

Understanding Mirror Margins

Rather than have the margins of your documents always be the same, you can use what Word calls "mirror margins." Here's ...

Discover More

Converting Numbers Into Words

Write out a check and you need to include the digits for the amount of the check and the value of the check written out ...

Discover More

Turning Off Automatic Sorting in PivotTables

Tired of your data being sorted when you create a PivotTable? Excel allows you to specify how the sorting should occur by ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Calculating an Average within a Date Range

Need to find an average of the values that fall within a date range? Excel provides a number of ways you can do this, ...

Discover More

Removing Duplicates at a Reduced Precision Level

The precision of numeric values you display in a worksheet can be less than what is actually maintained by Excel. This ...

Discover More

Producing an Array of Numbers

When working with arrays in a formula, it can be a bit confusing to understand how they work. In this tip I examine a ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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 2 + 2?

2024-12-07 05:23:21

JMJ

@J Woolley: thank you also !


2024-12-06 04:33:58

Kiwerry

@J Woolley: thank you for the additional information and the explanation of the curly brackets.


2024-12-05 17:10:02

J. Woolley

@Kiwerry and JMJ
It has come to my attention that the ZIPShorter macro in my first comment below might not work as intended:
1. If the selected ZIP codes are text formatted as Text, the macro's result is text (as expected).
2. If the selected ZIP codes are text formatted as General, the macro's result is numeric (not text).
3. If the selected ZIP codes are numeric formatted as Special Zip Code + 4, the macro's result is numeric with 4 leading zeros (like 00001-2345).
Willy Vanhaelen's ZIPShorter macro produces the same results.

Here's a version of my macro that prepends an apostrophe to always return text for the 3 cases listed above; it probably requires support for dynamic arrays (Excel 2021 or later) when the Selection is more than one cell:

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

Here's the equivalent version of Willy Vanhaelen's macro:

Sub ZIPShorter()
Selection = Evaluate(" ""'"" & IF({1}, LEFT(" & Selection.Address & ", 5)) ")
End Sub

Notice IF(1,...) is the same as IF(TRUE,...). With surrounding braces, {1} becomes an array constant with a single element. I believe Willy added braces like IF({1},...) to coerce the Application.Evaluate method to return an array result when the Selection is more than one cell. In this case the result is probably similar to a CSE (Ctrl+Shift+Enter) array.


2024-12-02 06:14:58

JMJ

@Willy Vanhaelen:
I'd be glad too to understand what is the purpose of the "...If{1}..." part in your formula...
Thank you


2024-12-02 05:58:25

Kiwerry

@Willy Vanhaelen and J. Woolley
Thank you for your interesting contributions on processing all of the cells in a selection.

@Willy Vanhaelen: If you have time, a brief hint on the use of the "...If{1}..." in your Evaluate statement would be appreciated.


2023-10-02 12:12:37

Surey Rios

This worked like a charm! Thanks!


2021-08-08 12:21:12

Willy Vanhaelen

@J. Woolley
I just found out that your version works in Excel 2019 but not in 2007. My version works in both.


2020-01-27 10:28:40

J. Woolley

@Willy Vanhaelen
Here's a simpler version of your one-liner:
Sub ZIPShorter()
Selection = Evaluate("LEFT(" & Selection.Address & ",5)")
End Sub


2020-01-25 12:07:53

Willy Vanhaelen

You can replace this macro with a one-liner:

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


This Site

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

Newest Tips
Subscribe

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.