+ Reply to Thread
Results 1 to 7 of 7

Thread: Counting occurrences in a range with more than 1 criteria

  1. #1
    Registered User
    Join Date
    02-10-2010
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2002
    Posts
    19

    Unhappy Counting occurrences in a range with more than 1 criteria

    Hi all,

    I'm fairly new to Excel, and I need help trying to figure out a function that will count all occurrences of either "SME" or "TSC" or "ICU" in a range of cells.

    The cells may have more than that text, but if one of them is in the cell within the range, I want it to count that cell.

    Example Range:

    A1 = SME / 2246
    B1 = 2246 / TSC
    C1 = 2246 / ICU
    D1 = VAC
    E1 = VAC

    I want it to return the value 3 because the range contains 3 occurrences of either "SME", "TSC" or "ICU"

    Can anyone help? I've looked on other forums all over the place and I couldn't find specifically what I was looking for.

    Any help would be greatly appreciated!

    Thanks in advance,

    Anthony
    Last edited by NBVC; 01-25-2011 at 11:50 AM.

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

    Re: Counting occurrences in a range with more than 1 criteria

    Try:

    =SUMPRODUCT(--(ISNUMBER(SEARCH({"SME","TSC","ICU"},A1:E1))))
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    01-24-2011
    Location
    South Carolina
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Counting occurrences in a range with more than 1 criteria

    COUNTIF will also work

    =COUNTIF(B2:B451,"SME") will yield a numerical count of that criteria in a given range

    (in this example, range is B2 to B451)



    Ahh - re-read post - MORE than 1 criteria - sorry.
    Last edited by Hang Glider; 01-24-2011 at 04:05 PM.

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

    Re: Counting occurrences in a range with more than 1 criteria

    The OP wants to know if either of those 3 would appear in A1:E1 and count all... as I understood it... you could add 3 countifs like yours (but needs wildcard because there could be other text in the cells), or another alternative with COUNTIF

    =SUM(COUNTIF(A1:E1,{"*SME*","*TSC*","*ICU*"}))
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  5. #5
    Registered User
    Join Date
    02-10-2010
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2002
    Posts
    19

    Smile Re: Counting occurrences in a range with more than 1 criteria

    You rock NBVC!!!! Thank you so much! I was trying to figure this out for so long and your formula is so clean! Way cleaner/shorter than what I was trying...LOL! The first example you gave wasn't working for some reason, but your last one did!

    Thank you to both of you for helping....and thanks again NBVC!!!

    Quote Originally Posted by NBVC View Post
    The OP wants to know if either of those 3 would appear in A1:E1 and count all... as I understood it... you could add 3 countifs like yours (but needs wildcard because there could be other text in the cells), or another alternative with COUNTIF

    =SUM(COUNTIF(A1:E1,{"*SME*","*TSC*","*ICU*"}))

  6. #6
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,056

    Re: Counting occurrences in a range with more than 1 criteria

    Quote Originally Posted by NBVC View Post
    Try:

    =SUMPRODUCT(--(ISNUMBER(SEARCH({"SME","TSC","ICU"},A1:E1))))
    For this one to work you need the separators in the array to change for a horizontal range, i.e.

    =SUMPRODUCT(--(ISNUMBER(SEARCH({"SME";"TSC";"ICU"},A1:E1))))

    Note the semi-colons

    because of the need to make those changes based on the orientation of the range, I'd say that the COUNTIF version is preferable assuming that's your only condition
    Audere est facere

  7. #7
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Counting occurrences in a range with more than 1 criteria

    Thanks daddylonglegs... should've thought of that.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

+ 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.2.0