+ Reply to Thread
Results 1 to 16 of 16

Extracting Words from Paragraph Excel cell that match a list of Possible words from list

Hybrid View

joshHammes Extracting Words from... 08-03-2017, 01:21 PM
FlameRetired Re: Extracting Words from... 08-03-2017, 02:02 PM
joshHammes Re: Extracting Words from... 08-03-2017, 02:28 PM
FlameRetired Re: Extracting Words from... 08-03-2017, 03:07 PM
joshHammes Re: Extracting Words from... 08-03-2017, 03:16 PM
JohnTopley Re: Extracting Words from... 08-03-2017, 03:29 PM
FlameRetired Re: Extracting Words from... 08-03-2017, 03:53 PM
joshHammes Re: Extracting Words from... 08-03-2017, 04:24 PM
protonLeah Re: Extracting Words from... 08-03-2017, 03:29 PM
FlameRetired Re: Extracting Words from... 08-03-2017, 04:52 PM
joshHammes Re: Extracting Words from... 08-03-2017, 05:22 PM
FlameRetired Re: Extracting Words from... 08-03-2017, 05:38 PM
joshHammes Re: Extracting Words from... 08-03-2017, 05:43 PM
protonLeah Re: Extracting Words from... 08-05-2017, 12:30 AM
joshHammes Re: Extracting Words from... 08-07-2017, 12:12 PM
FlameRetired Re: Extracting Words from... 08-07-2017, 02:40 PM
  1. #1
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Extracting Words from Paragraph Excel cell that match a list of Possible words from list

    Hello, I am trying to extract locations from 5,000 projects that I have in Excel 2013. In the cell is a 2-4 paragraph abstract from the project and within our locations. I compiled a list of all locations I thought would be possible which is a list of about 916. Problem is that I have no idea how to do this...
    I was able to extract 1 word into adjacent cell using

    =IFERROR(LOOKUP(1E+100,SEARCH(places[Column1],F23),places[Column1]),"")
    where places[column1] is the list of 916 locations and Column if is the column of Research abstracts. I have been trying all week and this is my first forum post. Any help would be appreciated. Thanks.
    Last edited by joshHammes; 08-03-2017 at 01:35 PM.

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    joshHammes welcome to the forum.

    Since I don't know where you want output in relation to the source data I output to the same row. This can be changed to suit. The formula is array entered and filled across. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    =IFERROR(INDEX(places,SMALL(IF(ISNUMBER(SEARCH(places,$A$1)),ROW(places)-MIN(ROW(places))+1),COLUMNS($B:B))),"")



    A
    B
    C
    D
    E
    F
    1
    Now is the time for all good men to come to the aid of their country.
    country
    aid
    time
    Dave

  3. #3
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Hey Dave, thanks for the help. Unfortunately, all that did when I pasted it in my workbook was pull the names of the places in the order they appeared on the list. It is almost as if it did not even read the cell with the paragraph in it. See image.
    Also, when I tried the array-enter, nothing happnened...Example.PNG

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Unfortunately, all that did when I pasted it in my workbook was pull the names of the places in the order they appeared on the list. It is almost as if it did not even read the cell with the paragraph in it.
    You hadn't mentioned this part.

    I'm not encouraged. From the looks of your screen shot a formula solution is impractical even for the formula I posted. The only "solution" I am likely to come up with will be a lengthy array formula. If you are not aware of it array formulas are resource heavy.

    Perhaps someone can come up with a VBA solution. Unfortunately I don't know enough VBA.

    Edit I'll see if I can roust up some specialist(s).
    Last edited by FlameRetired; 08-03-2017 at 03:12 PM.

  5. #5
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    okay thank you, in plain-English, can you tell me what your code does exactly?

  6. #6
    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
    30,736

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Attach a sample workbook (not image).

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate.

    Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Quote Originally Posted by joshHammes View Post
    okay thank you, in plain-English, can you tell me what your code does exactly?
    If you are asking about formula that will return the locations in the string:
    • Parse the string in memory (an array).
    • Use MATCH or SEARCH using places for the list of lookup values.
    • That returns another array.
    • Assign index numbers to those returns (another array)
    • Group the index numbers with SMALL.
    • Pass the indexed numbers to the INDEX first argument (the parsed array. Calculated yet a second time with all its arrays.)
    • Return what it finds.
    Last edited by FlameRetired; 08-03-2017 at 03:56 PM.

  8. #8
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    I attached an example workbook. I used a code that was able to pull one item out of the paragraph but I need to pull out all of them. Maybe you can look at it and see if there is a way to edit that formula. thanks!
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,936

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Provide a sample workbook with desired results:
    (How to) Upload a Workbook directly to the Forum
    (please do not post pictures or links to worksheets)
    • Click Advanced next to Quick Post button at the bottom right of the editor box.
    • Scroll down until you see "Manage Attachments",
    • Click the "Choose" button at the upper left (upload from your computer).
    • Select your file, click "open", click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Close the Attachment Manager window.
    • Click "Submit Reply"
    Note: Please do not attach password protected workbooks/worksheets
    Ensure to disable any Workbook Open/Autorun macros before attaching!
    Ben Van Johnson

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    I was able to do another array formula without parsing. With just the 22 rows and 13 columns of output (there could be more columns) it took 52+ seconds.

    FWIW here is the array formula I applied. You don't want to use this.

    Formula: copy to clipboard
    =IFERROR(INDEX(INDEX(places,N(IF(1,MATCH(SMALL(IF(ISNUMBER(FIND(LOWER(places),LOWER($F1))),
    (FIND(LOWER(places),LOWER($F1)))+ROW(places)/10^5),ROW(INDEX(A:A,1):INDEX(A:A,COUNT((FIND(LOWER(places),LOWER($F1))))))),
    IF(ISNUMBER(FIND(LOWER(places),LOWER($F1))),(FIND(LOWER(places),LOWER($F1)))+ROW(places)/10^5),0)))),COLUMNS($B:B)),"")

  11. #11
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Oh wow haha that is crazy.. I ran the formula yesterday that I sent you and it took about 10 minutes to do all 5,000 projects..
    My thoughts were if I could run the same formula on the adjacent cell and tell it that the value could not equal the value from the previous cell then I would be good to go.. Any thoughts?? thanks again.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    You're welcome.

    My thoughts were if I could run the same formula on the adjacent cell and tell it that the value could not equal the value from the previous cell then I would be good to go.. Any thoughts?? thanks again.
    I believe that would be impractical.

    I am still waiting to see if VBA solution(s) are proposed.

    There has to be a better way.

  13. #13
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Ok keep me posted

  14. #14
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,936

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Search column F and write a string of found locations in column G for each F cell
    Option Explicit
    
    Sub Macro1()
        Dim PlacesList      As Variant, _
            TestBlock       As Range, _
            Descriptions    As Long, _
            LastBlock       As Long, _
            Results         As String, _
            Loc             As Variant, _
            t0              As Double, _
            matches         As Long
            
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With 'application
        
        LastBlock = Cells(Rows.Count, "F").End(xlUp).Row
        
        PlacesList = WorksheetFunction.Transpose(Range("places").Value)
        t0 = Timer
        
        For Each TestBlock In Range("F1").Resize(rowsize:=LastBlock)
            'clear the holder string
            Results = ""
            
            'search for each possible place
            For Each Loc In PlacesList
            
                'check if it is followed by a space or period
                If InStr(TestBlock, Loc & " ") > 0 Or InStr(TestBlock, Loc & ".") Then
                    matches = matches + 1
                    If InStr(Results, Loc) = 0 Then
                    
                        'if found, append to the string
                        Results = Results & IIf(Results = "", "", ",") & Loc
                    End If
                End If
            Next Loc
            
            'write the found locations to column G
            TestBlock.Offset(columnoffset:=1).Value = Results
        Next TestBlock
        
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With 'application
        
        'report process time
        MsgBox "Process took: " & Timer - t0 & IIf((Timer - t0) > 1, " secs ", " sec ") & vbCrLf & "with " & matches & " matches found"
    End Sub
    Last edited by protonLeah; 08-05-2017 at 12:51 AM.

  15. #15
    Registered User
    Join Date
    08-01-2017
    Location
    Blacksburg
    MS-Off Ver
    2013
    Posts
    7

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    Quote Originally Posted by protonLeah View Post
    Search column F and write a string of found locations in column G for each F cell
    Option Explicit
    
    Sub Macro1()
        Dim PlacesList      As Variant, _
            TestBlock       As Range, _
            Descriptions    As Long, _
            LastBlock       As Long, _
            Results         As String, _
            Loc             As Variant, _
            t0              As Double, _
            matches         As Long
            
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With 'application
        
        LastBlock = Cells(Rows.Count, "F").End(xlUp).Row
        
        PlacesList = WorksheetFunction.Transpose(Range("places").Value)
        t0 = Timer
        
        For Each TestBlock In Range("F1").Resize(rowsize:=LastBlock)
            'clear the holder string
            Results = ""
            
            'search for each possible place
            For Each Loc In PlacesList
            
                'check if it is followed by a space or period
                If InStr(TestBlock, Loc & " ") > 0 Or InStr(TestBlock, Loc & ".") Then
                    matches = matches + 1
                    If InStr(Results, Loc) = 0 Then
                    
                        'if found, append to the string
                        Results = Results & IIf(Results = "", "", ",") & Loc
                    End If
                End If
            Next Loc
            
            'write the found locations to column G
            TestBlock.Offset(columnoffset:=1).Value = Results
        Next TestBlock
        
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With 'application
        
        'report process time
        MsgBox "Process took: " & Timer - t0 & IIf((Timer - t0) > 1, " secs ", " sec ") & vbCrLf & "with " & matches & " matches found"
    End Sub
    Hello Leah, Thank you very much! You are a lifesaver!
    Last edited by joshHammes; 08-07-2017 at 12:16 PM.

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Extracting Words from Paragraph Excel cell that match a list of Possible words from li

    @ joshHammes

    Glad you found it.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Replies: 1
    Last Post: 06-14-2016, 06:21 PM
  2. Match words from a list with strings in a excel column
    By rusd in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-23-2014, 10:00 AM
  3. Replies: 3
    Last Post: 08-14-2013, 10:38 AM
  4. Replies: 0
    Last Post: 04-29-2013, 03:13 PM
  5. Match part of cell to a list of words - Does not work with large data set
    By sdsu2010 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2013, 06:41 PM
  6. Replies: 3
    Last Post: 11-28-2012, 04:00 AM
  7. Replies: 1
    Last Post: 04-04-2012, 07:15 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