Results 1 to 8 of 8

Thread: And vs Or and Not Conditions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    NOTs in SUMPRODUCT and other array formulas can be quite tricky.

    Paul is right, the <> version that you are using is comparing each of the constant values against each of the cell values, so many are being counted multiple tim4es.

    The = test you originally used was using a neat shorthand version, but the not equal version can still be handled by SUMPRODUCT, by using a more 'structured' approach, using MATCH.

    So here, we would test whether any of the constant values are in the range using

    MATCH(MyContacts!$B$1:$B$4000,{"Teacher","","NA",1967,1976},0)
    This returns the position of the cell value in the constants array, or #N/A if not found. So we turn this to TRUE or FALSE by using ISNA against it

    ISNA(MATCH(MyContacts!$B$1:$B$40,{"Teacher","","NA",1967,1976},0))
    Unfortunately, the blank test does not work as you have it, so you need to add another test for that
    --(MyContacts!$B$1:$B$40<>"")

    In full, to get your count

    =SUMPRODUCT(--(MyContacts!$B$1:$B$40<>""),--(ISNA(MATCH(MyContacts!$B$1:$B$40,{"Teacher","NA",1967,1976},0))))
    Last edited by Bob Phillips; 06-13-2012 at 01:12 PM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •