+ Reply to Thread
Results 1 to 9 of 9

How to use SEARCH for word not embedded in another word?

  1. #1
    Registered User
    Join Date
    09-22-2017
    Location
    New York
    MS-Off Ver
    2010
    Posts
    3

    How to use SEARCH for word not embedded in another word?

    I am using the SEARCH function on a column of keywords, trying to match each cell to a list of words, and counting up how many keywords in that column have any of the words in a list. It all works fine except for one thing. If the list has a word that is short, sometimes a keyword that contains that short word within it gets counted.
    For example, let's say my list of words I care about are:
    • longword
    • dia
    • others
    Then my list of keywords I want to match to my word list is:
    • This is a longword
    • dials
    • dia
    • concordia
    • dia alone
    • just dia
    • others
    • blah

    So I only want to count the cells that have "dia" as its own word (in bold), not "dials" or "concordia." If this were a regular expression match, it would be easy. But how do I specify to Excel in a Search function that I only want these keywords when they match what's in the list only when it's got a space or beginning/end of line on either side?

    BTW, I am using the function =IF(SUMPRODUCT(--(ISNUMBER(SEARCH(listofwords,$A7))))>0,"found","") to do the matching, then have a COUNTIF at the bottom of the column to add up the cells with "found" in them.

    Thanks!

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to use SEARCH for word not embedded in another word?

    Try

    =IF(SUMPRODUCT(--(ISNUMBER(SEARCH(" "&listofwords&" "," "&$A7&" "))))>0,"found","")

  3. #3
    Registered User
    Join Date
    09-22-2017
    Location
    New York
    MS-Off Ver
    2010
    Posts
    3

    Re: How to use SEARCH for word not embedded in another word?

    Don't think that will work. "listofnames" in the SEARCH function is a named array, not a string.

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to use SEARCH for word not embedded in another word?

    Only 1 way to find out.

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to use SEARCH for word not embedded in another word?

    Jonmo, initially I was thinking the same thing but I could not get it to work when testing.

    It only seems to work for exact matches.

    See attachment.
    Attached Files Attached Files

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to use SEARCH for word not embedded in another word?

    Works for me, something is wrong with the spaces in the book you posted
    Retype the sentences in A1 A5 and A6 and it works.

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to use SEARCH for word not embedded in another word?

    Interesting, I copied and pasted the data from post #1.

    After changing the characters that look like spaces to actual spaces, the formula did indeed work.

  8. #8
    Registered User
    Join Date
    09-22-2017
    Location
    New York
    MS-Off Ver
    2010
    Posts
    3

    Re: How to use SEARCH for word not embedded in another word?

    Awesome! It worked! I didn't know you could put parameters on either side of a named array. Many thanks!

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to use SEARCH for word not embedded in another word?

    You're welcome.

+ 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. Excel VBA - Word to search for part of a word and replace full word
    By charlie543 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-24-2016, 02:56 AM
  2. Replies: 2
    Last Post: 04-29-2014, 10:06 AM
  3. Replies: 2
    Last Post: 08-05-2013, 04:45 PM
  4. Replies: 1
    Last Post: 01-25-2011, 10:50 PM
  5. How to search for a word in a column and have entire row opaque once word is found
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-04-2009, 07:11 PM
  6. [SOLVED] search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM
  7. Replies: 0
    Last Post: 01-23-2005, 03:06 AM

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