+ Reply to Thread
Results 1 to 31 of 31

How can i extract specific words from a cell?

  1. #1
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    How can i extract specific words from a cell?

    Is there a formula i can use to extract specific words in a cell?

    Hypothetical Example: Treat the below 3 lines as Column A, Rows 1,2 & 3. The words i would like to extract are the ones in bold text and not all of them will start with the word golf. Thanks in advance for your help

    Joes 9 hole golf course
    kyles 18 hole golf School
    looking for golf lessons

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    Unclear.................

    Do you want a formula that will return the contents of the cell with the last two words removed?
    Gary's Student

  3. #3
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    Unclear.................

    Do you want a formula that will return the contents of the cell with the last two words removed?
    It could be the last 2 words or the last 5,6,7 etc...Its different for each cell. I was hoping i can specify the exact text to extract from each cell but a formula to extract the last few words might work ill just have to modify the number of words for each cell.

  4. #4
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    I just attached a sample file, not sure if it will help any.
    Attached Files Attached Files

  5. #5
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    Here is a version that looks for "golf" and uses it for extraction
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    Here is a version that looks for "golf" and uses it for extraction
    I need the opposite of that, all the words in the beginning need to go away but its not just the golf words i need to keep i also need to keep the +CC, +GC, +Country club and other variations.

  7. #7
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    So:
    1. if "golf" is found in a cell, keep "golf" and everything following it
    2. if "golf" is not found in the cell, keep everything.

  8. #8
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    So:
    1. if "golf" is found in a cell, keep "golf" and everything following it
    2. if "golf" is not found in the cell, keep everything.
    Almost, these are all the terms i need to keep in each cell. Each cell contains just one of the terms below, I need to remove everything before each term regardless of whats before it so in the end all i will be left with is an excel sheet full of these terms. I have a total of 300,000 plaus cells with these terms in them.

    +cc
    +country +club
    +gc
    +golf
    +golf +club
    +golf +course
    +golf +deals
    +golf +discounts
    +golf +links
    +golf +rates
    +golf +reservations
    +golf +resort
    +golf +schedule
    +golf +tee +times
    +golf +times
    +green +fees
    +greens +fees
    +tee +schedule
    +tee +sheet
    +tee +time
    +tee +times
    Country club
    gc
    golf
    Golf Center
    golf club
    Golf Course
    golf deals
    golf discounts
    golf links
    golf rates
    golf reservations
    golf resort
    golf schedule
    golf tee times
    golf times
    green fees
    greens fees
    Resort and Golf Course
    tee schedule
    tee sheet
    tee time
    tee times

  9. #9
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Anyone have a solution?

  10. #10
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    I can do this with a macro (UDF).
    Is this acceptable??

  11. #11
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    I can do this with a macro (UDF).
    Is this acceptable??
    Sure anything that works im grateful for, i dont know how macros work but i know how to copy paste them into the macro tool lol.

  12. #12
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    Great!

    Here is a sample workbook with the User Defined Function (UDF) installed.

    We can use this workbook to make sure the UDF is satisfactory before you attempt to install it in your workbook.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    Great!

    Here is a sample workbook with the User Defined Function (UDF) installed.

    We can use this workbook to make sure the UDF is satisfactory before you attempt to install it in your workbook.
    Gah i dont know what happened i opened the file and it had the macro warning, i enabled it then the macro box came up and the name of the macro was the name of another file i had open so i hit cancel then i closed the other file went back to developer clicked macro and its empty. Dont know where it went, i even tried to re download the file and it still has no macro in it. Sorry for being such a noob!

  14. #14
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Wait i see this formula and it seems to work partially but although its searching the entire column N for a match its stopping at the first iteration of the word. So out of this word (Willowbrook golf deals) its only keeping golf when i need golf deals.


    =extractt(A1,N$1:N$43)

  15. #15
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    You are correct. It stops at the first match. Do you want it to continue to the last match??

  16. #16
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    If by last match you mean full match then yes so for example if its (Willowbrook golf deals) i would need only (golf deals) not both (golf) & (Golf Deals).

  17. #17
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    ..........
    Last edited by mikey42979; 06-13-2013 at 01:38 PM. Reason: Accidental post cant find the delete

  18. #18
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    Here is the updated version
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    Here is the updated version
    Ok this one is working but i dont undertsand how lol the formula looks identical to the first file? How would i install this fix into another workbook, you mentioned its a UDP but i dont see anything under macros?

  20. #20
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    Here is the latest UDF:

    Please Login or Register  to view this content.

    User Defined Functions (UDFs) are very easy to install and use:
    1. ALT-F11 brings up the VBE window
    2. ALT-I
    ALT-M opens a fresh module
    3. paste the stuff in and close the VBE window
    If you save the workbook, the UDF will be saved with it.
    If you are using a version of Excel later then 2003, you must save
    the file as .xlsm rather than .xlsx

    To remove the UDF:
    1. bring up the VBE window as above
    2. clear the code out
    3. close the VBE window

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    or

    http://www.cpearson.com/excel/Writin...ionsInVBA.aspx

    for specifics on UDFs

    Macros must be enabled for this to work!

  21. #21
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Ahhh another problem it wasnt fully working in the file mikey2, its not grabing the +symbols before the words. Sorry for this im sure your frustrated by now.
    Attached Files Attached Files
    Last edited by mikey42979; 06-13-2013 at 04:42 PM.

  22. #22
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    I see the problem!

    Row #29 fails to find the match because the comparison is case-sensitive. This means golf will match, but Golf will not.

    There are two possible solutions to this:

    1. make the comparison not sensitive to case
    2. add Golf to the lookup list

    Which would you like??

  23. #23
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Well its not just row 29 not matching mine doesnt match rows 4 & 5 through 17 for example in row 4 my result is showing gc not +gc and 6 im only seeing golf instead of +golf +club as the result. And it would also be better not case sensitve thanks.

  24. #24
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    Row #4 should show gc and not +gc because gc is lower down in the look-up list.

  25. #25
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Jakobshavn View Post
    Row #4 should show gc and not +gc because gc is lower down in the look-up list.
    Ok i get it now i thought it was doing exact match, is it possible to find the exact match string and also not be case sensitive? So +gc matches only +gc and gc matches only gc?

  26. #26
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How can i extract specific words from a cell?

    It IS an exact match. The problem is that the item in row #4 contains BOTH gc and +gc

  27. #27
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    I guess it wont work for what i need then thanks for the effort.

  28. #28
    Registered User
    Join Date
    06-13-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: How can i extract specific words from a cell?

    What are the items with a +?

  29. #29
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Quote Originally Posted by Maureen405 View Post
    What are the items with a +?
    Are you asking what the + means?

  30. #30
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    In the attached file i put a header on the column's and a brief explanation to help you guys understand better. Column B is an example of the results im trying to get thanks I hope its enough and easier to understand.
    Attached Files Attached Files

  31. #31
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    191

    Re: How can i extract specific words from a cell?

    Anyone have a solution to this?

+ 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