+ Reply to Thread
Results 1 to 3 of 3

2 condition countif function using AND

  1. #1
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    2 condition countif function using AND

    i just saw a post where the op used
    =COUNTIF(A$1:A$4,"<=0")*AND(COUNTIF(B$1:B$4,">=0"))
    to count on 2 criteria. and sad to say i cant see how it works!
    i'd use
    =SUMPRODUCT((A1:A4<=0)*(B1:B4>=0)) to do the same.
    its the use of the "and" thats thrown me whats the logic behind it.?
    Last edited by martindwilson; 04-13-2009 at 07:37 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Re: 2 condition countif function using AND

    Hi,

    =SUMPRODUCT((A1:A4<=0)*(B1:B4>=0)) to do the same
    Not in all cases

    All neg in column A, all pos in column B - same
    All neg in column A, all neg in column B - same
    All neg in column A, all neg in column B - same
    All neg in column A, any pos in column B - different

    *AND(COUNTIF(B$1:B$4,">=0")) this part just gives a TRUE or FALSE

    The OP can just use

    =COUNTIF(A$1:A$4,"<=0") to get the same result as

    =COUNTIF(A$1:A$4,"<=0")*AND(COUNTIF(B$1:B$4,">=0"))
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: 2 condition countif function using AND

    thanks i never actually tested the result without the *AND bit !
    i assumed that it was some wierd formula that id never seen before!

+ 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