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:
- Select the column (or cells) you want Excel to treat as text.
- Display the Home tab of the ribbon.
- Click the small icon at the lower-right corner of the Numbers group. Excel displays the Format Cells dialog box.
- Make sure the Number tab is selected. (See Figure 1.)
- In the list of available formats, choose Text.
- Click on OK.
Figure 1. The Number tab of the Format Cells dialog box.
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:
- Format the cells as Text.
- Select a cell that has a five-digit ZIP Code in it.
- Press F2. This informs Excel you want to edit the cell.
- Immediately press Enter. This tells Excel you are done editing the cell.
- Repeat steps 2 through 4 for each cell that contains a five-digit ZIP Code.
Once this process is done, you can sort the cells, as desired.