+ Reply to Thread
Results 1 to 10 of 10

How to get a Zip Code from an address

  1. #1
    Registered User
    Join Date
    12-07-2013
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2007
    Posts
    8

    How to get a Zip Code from an address

    Hi,

    I have a series of Data which has a complete address. I need to extract the Zip code from these addresses.

    Thank you very much.

    Greshan (Drgre)
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to get a Zip Code from an address

    Hi.

    In all of your examples, the string ends in "##### USA", where "#####" is the ZIP code. I presume, then, that this is always the case (otherwise you would surely have given some examples of different layouts)?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    12-07-2013
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to get a Zip Code from an address

    Yes. All the addresses has the below in common

    "State Prefix" "Zip Code" "USA"

    EG: RI 02914 USA

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to get a Zip Code from an address

    Thanks.

    =LEFT(RIGHT(A1,9),5)

    Or, if you need the result to be a numeric:

    =0+LEFT(RIGHT(A1,9),5)

    Regards

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: How to get a Zip Code from an address

    Hi Drgre,

    Here is a Control+Shift+Enter (CSE) array formula that will do what you need.

    =MAX(IFERROR(MID(A1,ROW(A1:A80),7)+0,""))

    See the attached.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to get a Zip Code from an address

    Quote Originally Posted by MarvinP View Post
    =MAX(IFERROR(MID(A1,ROW(A1:A80),7)+0,""))
    Not sure I understand, Marvin. The OP already confirmed that the format was fixed and identical for each string. Hence we can simply locate the ZIP code in the same place it will always be.

    Besides, what happens if there's another, larger number in the address somewhere? Granted, unlikely. But impossible?

    Or what does your formula return for e.g.:

    41 January Street, FLUSHING, NY 11355 USA

    ?

    Regards

  7. #7
    Registered User
    Join Date
    12-07-2013
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2007
    Posts
    8

    Thumbs up Re: How to get a Zip Code from an address

    Thank you very much XOR LX & MarvinP.

    I got the formula from XOR LX. But i was not able to figure out MarvinP's formula as it give "#Value" error.

    As usual you guys have being very helpful.

    (Unfortunately I don't know how to close this post, Can you guys help me on that as well)

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: How to get a Zip Code from an address

    Hey Xor LX,

    The formula looks down the string for 7 characters in a row that are completely numbers. My assumption is that there is a space in front and behind the 5 digit Zip code. I could have keyed on the "USA" but just wanted to show a different method. Here is another way using strings and now the "USA"

    =TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)*(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1),LEN(A1)))

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: How to get a Zip Code from an address

    After putting my formulas into the cell, instead of pressing enter, you need to hold the Control and Shift keys down and then press Enter. This makes it an Array Formula.

    To tag this thread as "Solved" you need to EDIT your original post, click on "Go Advanced" and change the prefix of the thread to "Solved".

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to get a Zip Code from an address

    Quote Originally Posted by MarvinP View Post
    Hey Xor LX,

    The formula looks down the string for 7 characters in a row that are completely numbers. My assumption is that there is a space in front and behind the 5 digit Zip code. I could have keyed on the "USA" but just wanted to show a different method.
    Sure, but it's not at all guaranteed to work in all cases! That was my point!

    Regar

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need VBA to look up for ZIP code in address column.
    By winmaxservices1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2015, 02:29 PM
  2. [SOLVED] Separate Zip Code from Address
    By geddes_3 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-13-2013, 07:39 PM
  3. Seperate/ Split Address and Pin code
    By n.aditya.k in forum Excel General
    Replies: 2
    Last Post: 11-06-2012, 02:15 AM
  4. Replies: 1
    Last Post: 03-08-2012, 01:57 PM
  5. How do I put the zip code in the address label?
    By xsell in forum Excel General
    Replies: 1
    Last Post: 12-01-2005, 11:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1