+ Reply to Thread
Results 1 to 15 of 15

Google Sheets: Extracting Zip codes with in multiple forms.

  1. #1
    Registered User
    Join Date
    08-07-2019
    Location
    Cincinnati, OH
    MS-Off Ver
    2013
    Posts
    12

    Google Sheets: Extracting Zip codes with in multiple forms.

    Hello! I need help finding a way to extract zip codes... the problem is is that there are some with 4 numbers after the dash and some without. but i need to extract either way. i have included some samples below, edited for privacy.... The entire block of text below is in its own cell (per row)

    6572 Jenn Dr Payton Township Ohio 48044-5972 USA
    5900 Timber Place Ave. Groplick Kentucky 49859 USA
    5359 Midsummer ave. Porktown Kentucky 41741 USA
    1443 Elk trotter ave Cowcity Ohio 45756 USA
    Last edited by AliGW; 06-25-2021 at 08:03 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Extracting Zip codes with in multiple forms.

    With Power Query it is a two step event in the UI. Here is the resulting Mcode.

    Please Login or Register  to view this content.
    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    1
    Column1 Column1.1.1 Column1.1.2 Column1.2
    2
    6572 Jenn Dr Payton Township Ohio 48044-5972 USA 6572 Jenn Dr Payton Township Ohio 48044-5972 USA
    3
    5900 Timber Place Ave. Groplick Kentucky 49859 USA 5900 Timber Place Ave. Groplick Kentucky 49859 USA
    4
    5359 Midsummer ave. Porktown Kentucky 41741 USA 5359 Midsummer ave. Porktown Kentucky 41741 USA
    5
    1443 Elk trotter ave Cowcity Ohio 45756 USA 1443 Elk trotter ave Cowcity Ohio 45756 USA
    6
    Sheet: Sheet1

    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-07-2019
    Location
    Cincinnati, OH
    MS-Off Ver
    2013
    Posts
    12

    Re: Extracting Zip codes with in multiple forms.

    Thank you for the response!

    that looks great, but lets say i only have access to Google Sheets, can i do this in there?

    Can this be done with a formula?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,215

    Re: Extracting Zip codes with in multiple forms.

    Try

    =SUBSTITUTE(IFERROR(IF(FIND("-",A1),RIGHT(A1,14)),RIGHT(A1,10)),"USA","")

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting Zip codes with in multiple forms.

    Edited: I may have misread the intent. This will extract the 5 character portion only.

    I've not worked with Google sheets but I have difficulty believing this won't work. With the posted data in column A this in B1 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 06-24-2021 at 05:52 PM.
    Dave

  6. #6
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Extracting Zip codes with in multiple forms.

    try this one
    =LEFT(RIGHT(A1,8),4)

  7. #7
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Extracting Zip codes with in multiple forms.

    sory my be this one
    =INT(LEFT(REPLACE(MID(A1,5,LEN(A1)),1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},MID(A1,5,LEN(A1))&1/17))-1,""),5))

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Extracting Zip codes with in multiple forms.

    Power Query is a Microsoft product that is part of Excel. It is not compatible with Google Sheets. Suggest in the future that you identify that you are working in Google Sheets so that those of us who don't will not be wasting our/your time with solutions that will not work for you.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: Google Sheets: Extracting Zip codes with in multiple forms.

    Moved to a more appropriate forum section, as the whole set-up, as explained above, was misleading from the start.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Registered User
    Join Date
    08-07-2019
    Location
    Cincinnati, OH
    MS-Off Ver
    2013
    Posts
    12

    Re: Extracting Zip codes with in multiple forms.

    Quote Originally Posted by alansidman View Post
    Power Query is a Microsoft product that is part of Excel. It is not compatible with Google Sheets. Suggest in the future that you identify that you are working in Google Sheets so that those of us who don't will not be wasting our/your time with solutions that will not work for you.
    sorry still new here

  11. #11
    Registered User
    Join Date
    08-07-2019
    Location
    Cincinnati, OH
    MS-Off Ver
    2013
    Posts
    12

    Re: Google Sheets: Extracting Zip codes with in multiple forms.

    sorry still new here, ill be careful with being more specific moving forward.

  12. #12
    Registered User
    Join Date
    08-07-2019
    Location
    Cincinnati, OH
    MS-Off Ver
    2013
    Posts
    12

    Re: Extracting Zip codes with in multiple forms.

    Quote Originally Posted by Ghozi Alkatiri View Post
    sory my be this one
    =INT(LEFT(REPLACE(MID(A1,5,LEN(A1)),1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},MID(A1,5,LEN(A1))&1/17))-1,""),5))
    giving me an error, doesnt like that the - is included as an integer

  13. #13
    Registered User
    Join Date
    08-07-2019
    Location
    Cincinnati, OH
    MS-Off Ver
    2013
    Posts
    12

    Re: Extracting Zip codes with in multiple forms.

    =SUBSTITUTE(IFERROR(IF(FIND("-",A1),RIGHT(A1,14)),RIGHT(A1,10)),"USA","")

    This one works with about a 99% success rate. some of the addresses have - in them in other places (1234 Gregory-johnson ave) which is causing some errors, but thats few and far between.

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Google Sheets: Extracting Zip codes with in multiple forms.

    Another way.

    In B1 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    1
    6572 Jenn Dr Payton Township Ohio 48044-5972 USA
    48044-5972
    2
    5900 Timber Place Ave. Groplick Kentucky 49859 USA
    49859
    3
    5359 Midsummer ave. Porktown Kentucky 41741 USA
    41741
    4
    1443 Elk trotter ave Cowcity Ohio 45756 USA
    45756

  15. #15
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,150

    Re: Google Sheets: Extracting Zip codes with in multiple forms.

    For Google Sheets, another alternative with RegExp;

    Please Login or Register  to view this content.

+ 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. [SOLVED] Compare JSON data and splitting into corrected codes, deleted codes and added codes
    By chandramouliarun in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-29-2020, 12:06 PM
  2. help with codes for extracting data
    By Navin Agrawal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2016, 04:02 PM
  3. [SOLVED] CHALLENGE: Extracting data from complex Excel Forms
    By buzzers88 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-11-2014, 03:24 PM
  4. Creating short forms for multiple codes
    By vgr in forum Excel General
    Replies: 7
    Last Post: 07-19-2014, 08:37 PM
  5. some codes to relate two user forms
    By bskaa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2013, 04:09 AM
  6. Extracting Metrics with Forms or Control
    By mycon73 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2010, 04:32 AM
  7. What codes can make Excel Macro to submit forms on web
    By FayettevilleEagles in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-16-2005, 09:40 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