View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Kevin B Kevin B is offline
external usenet poster
 
Posts: 1,316
Default mixing zip with zip+4 and then sorting

Create 2 side by side helper columns, one for the 5 digit zip prefix and
another for the 4 digit suffix. For the example I'll assume that the zip
codes start in D1:

In the first helper column enter the following formula to extract the 5
digit zip:

=LEFT(D1,5)

In the second helper column enter the following formula:

=IF(LEN(D1)=10,RIGHT(D1,4),"")

The IF statement only gets the 4 digits if the zip is 10 characters long.


Copy both formulas down to the last address in your table.

Now when you do your sort sort by the 5 digit zip formula column as your
primary and the 4 digit zip formula column as your secondary.

Hope this helps.
--
Kevin Backmann


"JWCrosby" wrote:

I have a zip code column that has both standard zips (5 digits) and zip +4
(00000-0000). When I sort by zip it sorts all the 5-digit zips separately
(at the beginning) from the zip+4. How can I get it to sort and mix them
together in proper order?