+ Reply to Thread
Results 1 to 8 of 8

In a single cell, count any occurrences from a list of values

  1. #1
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    In a single cell, count any occurrences from a list of values

    Title basically explains it all. I've tried to figure this out on my own but can't seem to find anything that works.

    First, I have a list of static values in a range I've named "friends":

    Brad
    George
    Jacob



    Elsewhere, I have cells which contain the following (each line of text would be in a single cell):

    Brad and george went to the store
    jacob jacob anderson jeff
    help me obibradkenobi you're my only hope
    333 jessica brad george brad


    For each of those above cells, I want to know how many times any of the values in "friends" appears in that cell. (It should not be case sensitive) So the results should be:

    2
    2
    1
    3

    Thanks!
    Last edited by daedelous00; 07-05-2013 at 02:50 PM. Reason: Change title, clarify question

  2. #2
    Forum Contributor
    Join Date
    03-11-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: In a single cell, count any occurrences from a list of values

    The text shown above for the values elsewhere in your spreadsheet, is each word a separate cell or does one cell have a litany of words?

  3. #3
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: In a single cell, count any occurrences from a list of values

    Quote Originally Posted by cheal2 View Post
    The text shown above for the values elsewhere in your spreadsheet, is each word a separate cell or does one cell have a litany of words?
    The latter. One cell would have a bunch of words in it.

    Additionally, something I didn't mention was that it should be able to find these words inside other words: like finding brad in "bradyellow" or george in "higeorgebanana." (Changing example in OP to reflect this...)

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: In a single cell, count any occurrences from a list of values

    daedelous00,

    Something like this should work for you:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Contributor
    Join Date
    03-11-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: In a single cell, count any occurrences from a list of values

    Assuming your list of names are set up in A1:A3 and your random text strings start on A5 - the following equation should work in B5:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: In a single cell, count any occurrences from a list of values

    cheal2,

    A few flaws with that formula:
    It doesn't used the named range, and it checks each cell individually. If his named range friends contains 10, or 20, or more cells, that is a lot of manual typing the formula and it will not scale well.
    FIND is case sensitive, so in his list, the names have the first letter capitalized but the the sentences are all lower case, so the FIND function will not find them. This can be gotten around either by coupling the FIND function with the LOWER (or UPPER) function, or by using the SEARCH function instead (SEARCH does the same thing as FIND, but it is not case sensitive).
    Lastly, if a name appears in a sentence more than once, it will still only be counted once, which would yield incorrect results given the fourth example sentence where "brad" appears twice.

  7. #7
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: In a single cell, count any occurrences from a list of values

    tigeravatar,

    That worked perfectly! Thanks!

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: In a single cell, count any occurrences from a list of values

    You're very welcome

+ 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