
Tips.Net > ExcelTips Home > Formatting > Sorting ZIP Codes
Summary: If you have both five- and nine-digit ZIP Codes in a column, you may have noticed that they don’t sort properly. The problem is related to how Excel treats the data, either numerically (five-digit codes) or as text (nine-digit codes). This tip explains how you can get the desired sorting results. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
ZIP Codes come in two flavors: five-digit codes and nine-digit codes. If you type a column of ZIP Codes into Excel--some five-digits and some nine--you may wonder why they don't sort correctly.
The reason is that Excel recognizes the five-digit codes as numeric entries, and the nine-digit codes as text entries. (It is the dash in the middle of the nine-digit codes that makes Excel treat the entry as text.) The problem with sorting the numbers is that Excel treats numeric and text values differently when sorting.
The solution (without resorting to formulas and additional columns for sorting) is to make sure that you force Excel to treat all your entries as text. You can do this by formatting a column as text before putting in your first ZIP Code. Simply follow these steps:
This formats the cells as text, and you can then sort the ZIP Codes correctly. Don't be misled here, however: You must make the format change before you enter values in the cells. If you format the cells as Text after you enter information, they still won't sort properly. You can do the following, however:
Once this process is done, you can sort the cells, as desired.
Tip #2793 applies to Microsoft Excel versions: 97 2000 2002 2003
Make Home Buying Less Stressful! Why face the annual problems associated with Christmas debt? Learn how to avoid that debt and conquer your financial challenges.
Check out Buying a Home Checklist today!
PivotTables don't need to be scary or mysterious. Use this powerful tool to analyze your data in ways you didn't know were possible. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
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