+ Reply to Thread
Results 1 to 3 of 3

Text Parsing??

  1. #1
    Registered User
    Join Date
    12-28-2006
    Posts
    42

    Text Parsing??

    Let me just say that I greatly appreciate the help I've received here over the last couple of days. Such a knowledgeable group and gave a total VBA noobie exactly what I was looking for. With that, I have another question.

    I have address information in one column that I need to parse out into new columns. Basically, I have a city state and zip with no delimiters other than spaces in one cell, and I need it to be in separate cells.

    Current Data Format:
    Row 2: |Granite Bay CA 95746|
    Row 3: |Galesburg IL 61401|
    Row 4: |Waukee IA 50263|

    What I need is this:
    |Column 1| |Column 2| |Column 3|
    |Granite Bay| |CA| |95746|
    |Galesburg| |IL| |61401|
    |Waukee| |IA| |50263|

    I know that my zip code is going to always be 5 characters long, and the state is going to be 2 characters long and was thinking of somehow working backwards to get the zip where it needs to be first, then the state, and leave the city alone since it wouldn't need to move in theory.

    Is there any way to do this in VBA or am I just over-complicating what I'm needing done?

    Thanks in advance!

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454
    Hi,

    Presuming your data starts at A1, put the following in B1, C1, and D1 to parse the text.

    =LEFT(A1,LEN(A1)-9)
    =MID(A1,LEN(A1)-7,2)
    =RIGHT(A1,5)
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    12-28-2006
    Posts
    42
    Once again, you folks have come through for me. Thanks a ton!

    Quote Originally Posted by sweep
    Hi,

    Presuming your data starts at A1, put the following in B1, C1, and D1 to parse the text.

    =LEFT(A1,LEN(A1)-9)
    =MID(A1,LEN(A1)-7,2)
    =RIGHT(A1,5)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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