+ Reply to Thread
Results 1 to 20 of 20

Counting number of times a word appears in a group of cells dynamically!

  1. #1
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Counting number of times a word appears in a group of cells dynamically!

    Evening everyone,

    I have an spreadsheet that contains text strings in cell B2:CE322.

    The text strings are in the following format, however contain a variety of names and numbers:

    Roger+1; Linda+4; Anne+3

    I want a function where I can count in the range B2:CE322 the number of times the following appears: Roger+1

    In this formular however, I want it to read in Roger from Cell A1 and the number 1 from A2. So if I want to change and count the number of times Linda+2 appears, I would change:

    Cell A1: From Roger to Linda
    Cell A2: From 1 to 2

    Hopefully someone will be able to help!

    Many thanks!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    Try

    =COUNTIF(B2:CE322,A1&"+"&A2)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    Many thanks NBVC, but unfortuantely the formula you suggested does not work

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    It worked for me.

    I have Roger in A1 and 2 in A2


    In a couple of cells within B2:CE322 I have entered "Roger+2" without quotes... and I got result of 2... as expected.

  5. #5
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    I am really sorry NBVC but I have done exactly what you have said, and I still get an answer of 0!

    I am using Excel 2007, does that make a difference?

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    This means that you don't have exact matches.

    Are you sure your inputs are in A1 and A2 not in A1 and B1? Also do the places that are supposed to match have extra leading/trailing spacesl?

    If still can't get it, can you attach a sample workbook showing incorrect results?

  7. #7
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    Hey NBVC,

    Thank you so much for all your help!

    This is the doc where I cannot get the formula to work!

    Cheers
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    Oops! Managed to get it to work :o)

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    I guess you figured out that the formula was inside the range you are looking in, therefore causing a circular reference... if you just drag that cell out to row 1, all is good

  10. #10
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    I have managed to get it to work if Roger+1 is just in the cell.

    There are some cells however that have the following in "Roger+1; Linda+4; Anne+3"

    If I put Roger in A1 and 1 in A2, I would still like Excel to count this!

    Also, if I put Linda in A1 and 4 in A2, again I would like excel to count the cell!

    Thanks again for all your help!

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    Change formula to:

    =COUNTIF(B2:CE322,"*"&A1&"+"&A2&"*")

  12. #12
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    Sorry to complicate things even further!

    I now have three cells containing:

    Linda+1, Roger+1, Gill+4
    Gill+4, Linda+1
    Roger+1, Linda+1

    In A1, I have Roger and in A2 I have 1
    In B1, I have Linda, and in B2 I have 1

    I now want Excel to count how many cells contain 'Roger+1' and 'Linda+1' together. They can be in either order however.

    So on the example above, the answer should be 2!

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    Try:

    =COUNTIFS(B2:CE322,"*"&A1&"+"&A2&"*",B2:CE322,"*"&B1&"+"&B2&"*")

  14. #14
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Counting number of times a word appears in a group of cells dynamically!

    Hello, Try this,

    Please Login or Register  to view this content.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    I just changed the formula.. I had previously thought you wanted an OR situation, but you want an AND situation....

  16. #16
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    Last complication! Promise!

    If I now change B2 to 0, I don't now want the formulae to count Linda either!

    The same is true with A2, if I change that to 0, I don't now want the formulae to count Peter either!

    Thanks guys!

  17. #17
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    So it should only count the number of cells that contains both the A1:A2 and B1:B2 terms? Or as long as one of the A1:A2 or B1:B2 terms exist it should count?

  18. #18
    Registered User
    Join Date
    05-26-2011
    Location
    Newcastle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Counting number of times a word appears in a group of cells dynamically!

    So keeping all of the functionality previously mentioned, I now have three cells containing:

    Linda+1, Roger+1, Gill+4
    Linda+1
    Roger+1, Linda+1

    In A1, I have Roger and in A2 I have 0
    In B1, I have Linda, and in B2 I have 1

    I would like a formula, which keeps all mentioned before functionality, however would only count cells which contain 'Linda+1'. i.e As A2 is 0, I don't want to count the word 'Roger' either!

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting number of times a word appears in a group of cells dynamically!

    Ok, I think I got you... try:

    Please Login or Register  to view this content.

  20. #20
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Counting number of times a word appears in a group of cells dynamically!

    Try,

    Please Login or Register  to view this content.

+ 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