+ Reply to Thread
Results 1 to 10 of 10

Finding exact word in an array of words

Hybrid View

  1. #1
    Registered User
    Join Date
    05-12-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    4

    Finding exact word in an array of words

    Hi all,

    I'm new here but hope to become a contributing member over time! I also hope I am not out of line with posting my question to a problem I have encountered.

    Goal: to determine if a word matches exactly in an array of words.

    Description: I have a list of words that I am trying to see if they are present in particular cells

    List of words (contained in a separate work sheet called Keyword Types:
    who
    what
    when
    where
    why
    how
    can
    is
    ?

    Cell phrases:
    how do I calculate the chi square test?
    when will I get my marks back?
    regression line
    understanding the p-value
    thesis of mathematical significance


    Here is the function I've come up with:

    {=IF(SUM(NOT(ISERROR(FIND('Keyword Types'!$A$2:$A$2,$A2)))*1)>0,G$1,"Non-"&LOWER(G$1))}
    Now, my code does work as expected, too well is the problem because when I copy the code for each cell it will match the word "is" to the cell phrase "thesis of mathematical significance" since the phrase contains the word "is" but that's not what I am trying to do obviously.

    Does anyone have some insight on how I may be able to revamp my function to match whole words only?

    Thank you!!

    Regards

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Finding exact word in an array of words

    Suggest that you actually search for the word with a space on either side or a space at the front and comma/full top at the end.

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

    Re: Finding exact word in an array of words

    Hi
    My formula is

    =IF(ISERROR(MATCH(LEFT(A1,FIND(" ",A1)-1),'Keyword Types'!$A$1:$A$8,0)),"Doesn’t Exist","Exists")

    your data starts from a1 cell and keywords in Sheet "Keyword types" a1:a8

    Formula assumes that keywords will be first word in data beacuse they are questions.....
    Attached Files Attached Files
    Appreciate the help? CLICK *

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Finding exact word in an array of words

    Formula: copy to clipboard

    B2:
    =IF(COUNT(INDEX(SEARCH(" "&'Keyword Types'!$A$1:$A$9&" "," "&$A2&" "),0)),G$1,"Non-"&LOWER(G$1))
    copied down


    Assumes keywords are in A1:A9 and A2 holds first phrase - and that case sensitivity is not an issue (apple and Apple would be a match).

  5. #5
    Registered User
    Join Date
    05-12-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Finding exact word in an array of words

    Quote Originally Posted by DonkeyOte View Post
    Formula: copy to clipboard

    B2:
    =IF(COUNT(INDEX(SEARCH(" "&'Keyword Types'!$A$1:$A$9&" "," "&$A2&" "),0)),G$1,"Non-"&LOWER(G$1))
    copied down


    Assumes keywords are in A1:A9 and A2 holds first phrase - and that case sensitivity is not an issue (apple and Apple would be a match).
    First off, thanks to ALL for your generous help!!!

    Secondly, this works amazingly well! You are a God!

    One small question/hiccup. It does not seem to like searching for question marks (?). Do I need to escape the character some how so that excel recognizes it as a character/word to search on?

    Thanks again everyone!

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Finding exact word in an array of words

    Nice DonkeyOte,

    Like the idea of performing the search on the phrases after first inserting additional spaces at the start and end which takes away the otherwise tricky issue of dealing with start- and end-of-phrase matches separately.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Finding exact word in an array of words

    Yes, sorry, ? is a wildcard (single character) so you should precede with tilde in your keyword list, i.e. replace ? with ~?

    edit: may have an issue given that is not a single word (ie encasing within space)
    Last edited by DonkeyOte; 05-12-2013 at 02:54 PM. Reason: ~ !

  8. #8
    Registered User
    Join Date
    05-12-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Finding exact word in an array of words

    Quote Originally Posted by DonkeyOte View Post
    Yes, sorry, ? is a wildcard (single character) so you should precede with tilde in your keyword list, i.e. replace ? with ~?

    edit: may have an issue given that is not a single word (ie encasing within space)
    hmm you're right.

    DonkeyOte a God? does not get captured whereas DonkeyOte a God ? does get captured it seems.

    weird!

    I think this may be good enough anyways...

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Finding exact word in an array of words

    Apologies but I am heading offline for a little while... if the ? is the exception (i.e only non word) then you could modify for that specific instance - alternatively if you intend to have multiple punctutation type keywords and no 1 length words (a, i) then you could modify based on length - e,g

    Formula: copy to clipboard

    COUNT(INDEX(SEARCH(LOOKUP(LEN('Keyword Types'!$A$1:$A$9),{1,2},{"~"," "})&'Keyword Types'!$A$1:$A$9&LOOKUP(LEN('Keyword Types'!$A$1:$A$9),{1,2},{"~"," "})," "&$A1&" "),0))

  10. #10
    Registered User
    Join Date
    05-12-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Finding exact word in an array of words

    Quote Originally Posted by DonkeyOte View Post
    Apologies but I am heading offline for a little while... if the ? is the exception (i.e only non word) then you could modify for that specific instance - alternatively if you intend to have multiple punctutation type keywords and no 1 length words (a, i) then you could modify based on length - e,g

    Formula: copy to clipboard

    COUNT(INDEX(SEARCH(LOOKUP(LEN('Keyword Types'!$A$1:$A$9),{1,2},{"~"," "})&'Keyword Types'!$A$1:$A$9&LOOKUP(LEN('Keyword Types'!$A$1:$A$9),{1,2},{"~"," "})," "&$A1&" "),0))
    Thanks again for your help. It took some time for me to figure out how to work with what you wrote but I eventually got it humming nicely!

    Here's what the final code looks like:
    =IF(COUNT(INDEX(SEARCH(LOOKUP(LEN('Keyword Types'!$A$2:$A$14),{1,2},{"~"," "})&'Keyword Types'!$A$2:$A$14&LOOKUP(LEN('Keyword Types'!$A$2:$A$14),{1,2},{"~"," "})," "&$A22&" "),0)),I$1,"Non-"&LOWER(I$1))
    I really appreciate your efforts. You saved me SEVERAL hours of sorting through data and categorizing crap lol

+ 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