You are viewing the article OpenOffice.org Training, Tips, and Ideas: Sorting mixed 5- and 9-digit zip codes in OpenOffice.org Calc or Microsoft Excel at Lassho.edu.vn you can quickly access the necessary information in the table of contents of the article below.
Every advance leads to benefits and to problems.
The 9-digit zip code is great for delivery accuracy. But they aren’t required. So you have mixed 5-digits and 9-digits.
Now just try sorting your address info by zip code when there’s mixed 5s and 9s. Here’s what you get when you sort a standard address list by zip code. It’s like cattle and sheep, they don’t mix.
What do you do?
There are three things you can do:
1 – Enforce a 9-digit zip. Everyone without four digits gets -0000 whether they want it or not.
2 – Put a ‘ in front of every zip code. It doesn’t print but it forces the zip code to think of itself as text. (This also helps with not losing leading zeroes.)
3 – Split the column into two, so you have the zip in one column and the four-digit extension in the other. This is kind of like the forcing-9-digit solution.
The explanations follow but if you want to root around in an example spreadsheet, here’s a spreadsheet with options 2 and 3.
Solution 1
Solution 1 is self-explanatory.
Solution 2
Just type a ‘ a regular apostrophe on the keyboard, to the left of the first character of every zip code. It doesn’t show but it forces text format.
See? The ‘ is there in the entry field but it doesn’t show in the spreadsheet cell.
Typing ‘ into thousands of cells takes a while. So you can search and replace. There might be a better way to do this but this at least doesn’t suck.
Click in the Zip Code heading in your spreadsheet, then choose Edit > Find and Replace. Click More Options and fill out the window as shown, searching for ^0, caret zero, and replacing with ‘0, apostrophe zero.
You’ll need to do this once for 0, then for 1, then for 2, and so on. (I’ve tried to figure out a faster way, plus submit any suggestions.)
Either replace one at a time if you’re cautious, or go nuts and replace all. You might want to select the whole column of zip codes, too, and select the Current Selection Only checkbox.
When you’re done, and when you sort that data, the zip codes sort correctly.
Solution 3
You can split your data into two cells with the LEFT and RIGHT functions. I’m throwing in IF too because sometimes you’ll want the right-hand four digits (the extension) and sometimes you’ll want 0000. (Or just leave it blank, whatever you want to do.)
This is what I want to achieve.
And this is how I get it. The formula for the first column, where I extract the first five digits, is simple.
The right-hand side is a little more complicated since you’re dealing with variable-length zip codes. But basically you’re saying if the zip code is just five digits, then create a new 4-digit extension, “-0000” (or just “0000” depending on how you want to deal with the dash). And then if it isn’t just five digits, then you want to see the right-hand five digits of the zip code (including the dash) or the right-hand four digits (if you want to leave out the dash and put it in manually somehow).
Then you just drag down those formulas to all the zip code cells.
If you want to turn those columns into normal text, just copy them, choose Edit > Paste Special, choose to NOT paste formulas, and click OK.
The pasted results are nothing but numbers.
Now when you sort, you just need to be sure to do it by two levels, first by the main zip code, then by the extension. BE SURE that you set the Ascending or Descending the same for both.
And you get your results, sorted correctly.
Here’s a spreadsheet with options 2 and 3.
Thank you for reading this post OpenOffice.org Training, Tips, and Ideas: Sorting mixed 5- and 9-digit zip codes in OpenOffice.org Calc or Microsoft Excel at Lassho.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: