+ Reply to Thread
Results 1 to 9 of 9

Counting occurrences of specific text but only once for each cell

  1. #1
    Registered User
    Join Date
    10-08-2010
    Location
    North Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    69

    Counting occurrences of specific text but only once for each cell

    hello

    I'm using the COUNTIF function to count the number of instances of a particular word in a range of cells. However I only want to count that word once if it appears more than once in a cell. For example

    A1 apple
    A2 pear
    A3 red apples and green apples
    A4 banana

    Using COUNTIF(A1:A4,"*apple*") to find how many cells contain the word "apple" (doesn't matter if singular or plural) gives the answer of 3 (1 in A1 & 2 in A3) whereas the desired answer is 2. This being derived from A1 & A3 both containing the word "apple" irrespective of how many times it occurs in any given cell.

    Thanks in anticipation

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

    Re: Counting occurrences of specific text but only once for each cell

    Are you sure - it seems to give the answer 2 for me.
    Martin

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

    Re: Counting occurrences of specific text but only once for each cell

    DavidBW,

    Did you actually try that formula? The result is in fact 2.
    Hope that helps,
    ~tigeravatar

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

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting occurrences of specific text but only once for each cell

    Take a look to the example,pls.
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

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

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Registered User
    Join Date
    10-08-2010
    Location
    North Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Counting occurrences of specific text but only once for each cell

    thank you guys, my original list is so long that I just assumed it would count all occurrences. Would it be appropriate to ask how you can count all occurrences i.e. getting the answer 3 in the original example (or should I open a new thread?)

  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: Counting occurrences of specific text but only once for each cell

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting occurrences of specific text but only once for each cell

    Something like this?

    =SUMPRODUCT((LEN(A1:A4)-LEN(SUBSTITUTE(A1:A4,"apples",""))))/6

  8. #8
    Registered User
    Join Date
    10-08-2010
    Location
    North Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Counting occurrences of specific text but only once for each cell

    Fotis,
    what does the /6 at the end of your formula do?

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting occurrences of specific text but only once for each cell

    Take a look to the example to see with and without "/6"
    Attached Files Attached Files

+ 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