+ Reply to Thread
Results 1 to 12 of 12

Pulling specific text from cells

  1. #1
    Registered User
    Join Date
    11-09-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    26

    Pulling specific text from cells

    Good morning,

    I deal with a monthly report that tracks vehicles that are sold each month. The data is pulled directly through our application/collection system. The report will spit out the vehicle's make in column A and the vehicle's model in column B. The issue I'm having is since it's pulled directly from our application, it pulls the exact vehicle name, when in reality I need it simplified. Take the following examples:

    A1: Chevrolet Truck | B1: Tahoe-V6 XL
    What I need/want A1: Chevrolet | B1: Tahoe

    Another example:

    A2: Dodge Truck | B2: RAM 1500 EXL-5 Series
    What I need/want A2: Dodge | B2: Ram 1500

    As it stands, I'm currently just going throw the columns manually and deleting all the extra text, but it would be great if I could simplify this.

    Thank you,

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Pulling specific text from cells

    Try this:

    • Select a single-column range of text...Example: A2:A100
    • Data.Text-to-columns
    ...Click: Delimted...Click: Next
    ...Check: Space...Click: Next
    ...For each column after the first...Check: Do not import column (skip)
    ...Click: Finish

    Now that range will only contain the first word of the original text.

    • Repeat for the second column


    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Pulling specific text from cells

    Please give more sample data; I know how to do this.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Pulling specific text from cells

    Fixing A is simple enough:

    =LEFT(A1,FIND(" ",A1)-1)

    but B is more tricky. From B1 you want part of the first word returned (just Tahoe i.e just up to the -) and from B2, the first two "words" (Ram 1500). Is that correct?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    11-09-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Pulling specific text from cells

    I apologize if this isn't the most correct/efficient way to show more data, but I've extracted a portion to see:

    http://i.imgur.com/PBHQAFf.png

    You'll see that there is a lot of additive text specifically in the column for model. So I'd be looking to get rid of all extra text bout 4/6 cylinders or V6 and V8 text, XL's, SLE's, etc. (basically anything that does not simply say "F150" or "Cobalt" or "Altima".

    As for your suggestion Ron, I'm not sure that it would work since some of the make/models I would want more than the first word, IE: "Grand Caravan"

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Pulling specific text from cells

    The problem is that there are no logical rule(s) for what you want for the model. It's not the first word, or the text to the left of a "-" or whatever. i don't see any obvious way forward.

  7. #7
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Pulling specific text from cells

    This uses my extension/wrapper function FUZZYMATCH, based on this amazing algorithm called Levenshtein that I discovered here:
    http://superuser.com/questions/43738...rings-in-excel

    Never mind the sample data. Here you go:
    make_models_cy.xlsm

    fuzzy_match.JPG

    Edit: Although a looping substring search would do an adequate job in this case, you'll find that this algorithm will even handle typos.
    Last edited by cyiangou; 08-19-2015 at 11:24 AM.

  8. #8
    Registered User
    Join Date
    11-09-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Pulling specific text from cells

    Oh that's really cool. I had never heard of fuzzymatch. That was quite simple. Thank you!

  9. #9
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Pulling specific text from cells

    FUZZYMATCH is a wrapper I wrote. The magical bit is Levenshtein. You'll find all the code in the modules.

    If you liked this answer, please consider clicking the 'Add reputation' star to the left. Also use thread tools at the top to mark a thread as solved.

  10. #10
    Registered User
    Join Date
    11-09-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Pulling specific text from cells

    @Cyiangou

    I'm back and I had some additional questions about Fuzzymatch. This function has worked for me about 90-95% of the time, but I still have some issues with it. Take the following examples:

    1) Make: Ford Truck. Resolved Make becomes Roadtrek presumably due to the similarities in characters
    2) Make: Aveo Special Value. Resolved Make becomes Escalade presumably for the same reason

    There are some other examples where due to all of the extra text in the make, it will occasionally match it with an incorrect make.

    Thoughts?

  11. #11
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Pulling specific text from cells

    Being a 'fuzzy' match, you should expect that it will sometimes make an incorrect choice.

    I would try modifying the target makes list to make each of the targets much more specific, even if the makes that are being output are not quite what you need. eg Fordx. After getting an unambiguous match, you can then revert it back to its correct spelling.

  12. #12
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Pulling specific text from cells

    Given that you probably don't have to deal with typos like 'Ddge Truck', you can try this much simpler function that does a substring search, as I mentioned in #7.

    Please Login or Register  to view this content.
    Last edited by cyiangou; 08-28-2015 at 10:53 PM.

+ 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] Pulling specific text within a text in which the information is typed differently
    By djmatok in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-02-2014, 06:11 PM
  2. Pulling Out specific Text
    By Hollow55 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-04-2013, 04:56 AM
  3. Replies: 3
    Last Post: 12-20-2012, 01:16 AM
  4. [SOLVED] Pulling specific TEXT out of a string of varying length
    By Lasloja in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-28-2012, 05:26 PM
  5. [SOLVED] Pulling specific text string from a cell
    By smtwidle in forum Excel General
    Replies: 6
    Last Post: 06-25-2012, 03:28 PM
  6. Pulling specific parts out of text in a cell.
    By Befuddled in forum Excel General
    Replies: 3
    Last Post: 06-12-2010, 01:51 AM
  7. pulling specific text from a notepad document
    By smoosh1011 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2009, 05:10 PM

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