+ Reply to Thread
Results 1 to 5 of 5

Counting a column based on two sets of criteria

  1. #1
    Registered User
    Join Date
    06-24-2009
    Location
    Royersford, Pa
    MS-Off Ver
    Excel 2007
    Posts
    89

    Counting a column based on two sets of criteria

    Hello again!

    I'm using a sumproduct forumla to count rows based on specific data in multiple columns. So if column A equals 1 and column G does not equal 6 and column M equals 4 then count that row. I know how to do this. The problem I'm having is that I want to count column A if equals 1 or 2. I tried adding an OR comand in with my sumproduct but it doesn't seem to work that way. Any ideas? Thanks
    Last edited by Cjax; 07-23-2009 at 01:24 PM.

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

    Re: Counting a column based on two sets of criteria

    =sumproduct(--(a1:a4=1)+(a1:a4=2),--(g1:g4<>6),--(h1:h4=4))))
    Last edited by martindwilson; 07-23-2009 at 12:47 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

  3. #3
    Registered User
    Join Date
    06-24-2009
    Location
    Royersford, Pa
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Counting a column based on two sets of criteria

    It worked alright but I can't follow the logic behind it at all. Can you explain why it works. Im not familar with using -- in formulas or why you placed them where you did. Thanks again

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

    Re: Counting a column based on two sets of criteria

    -- simply changes true/false to 1/0
    same as using
    g1:g4<>6)*(h1:h4=4) in which true *true =1 true*false=0

  5. #5
    Registered User
    Join Date
    06-24-2009
    Location
    Royersford, Pa
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Counting a column based on two sets of criteria

    So I can use
    )*( or ,-- interchangeably?

+ 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