+ Reply to Thread
Results 1 to 12 of 12

Extracting Text From Cells of Variable Lengths

Hybrid View

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Question Extracting Text From Cells of Variable Lengths

    Hello, let me show you what I'm up against...

    A:
    1: AURORA, OH 44202 USA BEACHWOOD, OH 44122 USA BEACHWOOD, OH 44122 USA
    2: MENTOR, OH 44060 USA BEACHWOOD, OH 44122 USA AVON, OH 44011 USA


    I would like to extract the final 'City, State, Zip, USA" from each cell 'A' and put it in cell B. But BEACHWOOD and AVON are different lengths. Any suggestions?

    Thanks so Much!
    stinkstik
    Last edited by stinkstik; 04-25-2013 at 02:41 PM.

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Extracting Text From Cells of Variable Lengths

    Copy column A to column B.
    select column B
    Data>text to columns
    Delimited by comma
    delete columns B:D

  3. #3
    Registered User
    Join Date
    04-25-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extracting Text From Cells of Variable Lengths

    Hey Neil_,

    Thanks so much for taking the time to reply, but delimiting by comma and deleting cells B and D just leaves me with a result of " OH 44077 USA | GATES MILLS OH 44122 USA". Maybe I can rephrase...

    I would like to receive a final result of "BEACHWOOD, OH 44122 USA" all in one cell. I would like the comma included with data on either side, therefore I can't delimit by comma. I have a list of thousands of addresses of different lengths so I can not delimit by one single factor. Therefore a function is needed.

    Thanks!

  4. #4
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Extracting Text From Cells of Variable Lengths

    Does the last instance of 'USA' always immediately precede the data you are after? Or should I say the second one?

  5. #5
    Registered User
    Join Date
    04-25-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extracting Text From Cells of Variable Lengths

    Yes. There are always 3 instances of 'USA'. "City, State Zip USA City, State Zip USA City, State Zip USA". I've been trying to combine the RIGHT function with SEARCH or FIND functions but so far to no avail. But I'm probably missing a step.

    I appreciate your time!

  6. #6
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Extracting Text From Cells of Variable Lengths

    If the address always look like this:-


    someplace USA some other part of address USA the end bit Im after USA

    then select the entire column, press CTRL H and substitute USA with a character you know isn't in the list such as ^ or %. then delimit by that character. You can always concatenate " USA" to the end of the addresses afterwards

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Extracting Text From Cells of Variable Lengths

    First you use the solution of Neil (in #2)

    After that you can collect the desired outcome in one cell e.g. column Z
    e.g.=> = a1 & ", " & c1
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  8. #8
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Extracting Text From Cells of Variable Lengths

    Hi
    For each criteria I used seperate formulas
    city: =TRIM(MID(SUBSTITUTE(A2,"USA","#",2),FIND("#",SUBSTITUTE(A2,"USA","#",2))+1,FIND(",",SUBSTITUTE(A2,"USA","#",2),FIND("#",SUBSTITUTE(A2,"USA","#",2)))-FIND("#",SUBSTITUTE(A2,"USA","#",2))-1))

    State =LEFT(A2,FIND(",",A2)-1)

    Zip =MAX(IFERROR(1*MID(A2,MIN(SEARCH({0;1;2;3;4;5;6;7;8;9},LEFT(A2,FIND("USA",A2))&"0123456789")),ROW($1:$100)),0))

    USA =RIGHT(A2,3)


    Uploading file
    Attached Files Attached Files
    Appreciate the help? CLICK *

  9. #9
    Registered User
    Join Date
    04-25-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extracting Text From Cells of Variable Lengths

    Hey AZ-XL,

    Thanks for your reply. That looks pretty intense! I will definitely study your solution and try to learn from it.

    Thanks again!

  10. #10
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Extracting Text From Cells of Variable Lengths

    Quote Originally Posted by stinkstik View Post
    Hey AZ-XL,

    Thanks for your reply. That looks pretty intense! I will definitely study your solution and try to learn from it.

    Thanks again!
    Your are welcome.

  11. #11
    Registered User
    Join Date
    04-25-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extracting Text From Cells of Variable Lengths

    Neil_ you are a genius!!!!! I had no idea about that CTRL H function! It seems so simple! Thanks so much!

  12. #12
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Extracting Text From Cells of Variable Lengths

    Glad it worked for you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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