+ Reply to Thread
Results 1 to 5 of 5

If/OR and COUNTIF together

  1. #1
    Registered User
    Join Date
    09-21-2006
    Location
    Dallas, Texas
    MS-Off Ver
    Office 365 Subscription
    Posts
    56

    If/OR and COUNTIF together

    In cells e2:e51 there are several options available in a drop down list (pulled from cells U20:U35). I want to count the number of times the selections from U20,U26, U32 and U38 show up. I am not getting any results with the formula I have below...

    =IF(OR(COUNTIF(E2:E51=U$20,E2:E51=U$26,E2:E51=U$32),""))

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,492

    Re: If/OR and COUNTIF together

    Maybe:

    =COUNTIF(E2:E51,U$20)+COUNTIF(E2:E51,U$26)+COUNTIF(E2:E51,U$32)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: If/OR and COUNTIF together

    i don't know how robust this formula is in the context of your data, revert here in case of issues.

    for textual values in cells U20, U26, U32 and U38:

    =sum(countif($e$2:$e$51,t(indirect("u"&{20,26,32,38}))))

    for numerical values in column U, change "t" to "n" (without quotes).

    mind you, if you have duplicate (non-unique) values amongst cells U20, U26, U32 and U38, this formula will output incorrect result (basically, it will count those duplicate values multiple times).

    1006
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: If/OR and COUNTIF together

    SUMPRODUCT versions of the two suggested solutions

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: If/OR and COUNTIF together

    a couple of more suggestions (for non-contiguous cells) to eschew functions such as the volatile INDIRECT, and the restrictive N or T...

    =sum(index(countif($e$2:$e$51,choose({1,2,3,4},$u$20,$u$26,$u$32,$u$38)),0))

    i have read conflicting information about the limit on the number of arguments that CHOOSE can take (29 vs 254). hence, another option without any such known limitation:

    =sum(countif($e$2:$e$51,lookup({20,26,32,38},row($u$20:$u$38),$u$20:$u$38)))

    these two will not clam up in case they encounter both textual and numerical values in column U (the formula in post #3 could handle one or the other).

    1008
    Last edited by icestationzbra; 12-12-2012 at 03:32 PM.

+ 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