+ Reply to Thread
Results 1 to 12 of 12

nested countif

  1. #1
    Registered User
    Join Date
    07-06-2009
    Location
    zürich, switzerland
    MS-Off Ver
    Excel 2003
    Posts
    36

    nested countif

    hello

    im trying to create a formula with two conditions

    ex:
    i have two collumns
    A with names
    B with ages

    i need to sum fex. all those who are named "john" and are 23

    its basically a simple IF(name==john&&age=23)

    is that possible somehow?
    i thougth about a nested countif. but somehow thats not working

    thanks
    Last edited by f_mayr; 07-07-2009 at 06:45 AM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,445

    Re: nested countif

    Hi,

    How about this:

    =SUMPRODUCT((A1:A100="John")*(B1:B100=23))

    Obviously change the ranges to suit your data
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: nested countif

    To count the number of people named John who are aged 23 try the following:

    Please Login or Register  to view this content.
    Note that the range length must be the same in each part (a1:a20 and b1:b20)
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

  4. #4
    Registered User
    Join Date
    07-06-2009
    Location
    zürich, switzerland
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: nested countif

    thats what i needed thanks.

    but another question. isnt it possible to paste this over the whole column?

    like this:
    =SUMPRODUCT(--(_23.06.2009!$G:$G="John");--(_23.06.2009!$H:$H=23))

    _23.06.2009 beeing the sheet name
    Last edited by f_mayr; 07-07-2009 at 06:34 AM.

  5. #5
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,445

    Re: nested countif

    Quote Originally Posted by f_mayr View Post
    thats what i needed thanks.

    but another question. isnt it possible to paste this over the whole column?

    like this:
    =SUMPRODUCT(--(_23.06.2009!$G:$G="John");--(_23.06.2009!$H:$H=23))

    _23.06.2009 beeing the sheet name

    Not until you upgrade to XL2007

  6. #6
    Registered User
    Join Date
    07-06-2009
    Location
    zürich, switzerland
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: nested countif

    crap.

    thanks anyway for the answers!

  7. #7
    Registered User
    Join Date
    07-06-2009
    Location
    zürich, switzerland
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: nested countif

    ah there has just appeared a new problem

    is it possible to sort on a negative term?

    meaning everybody whos name is NOT john and is 23...

  8. #8
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,445

    Re: nested countif

    Yup,

    =SUMPRODUCT(NOT(A1:A100="John")*(B1:B100=1))

  9. #9
    Registered User
    Join Date
    07-06-2009
    Location
    zürich, switzerland
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: nested countif

    edit: to slow

  10. #10
    Registered User
    Join Date
    07-06-2009
    Location
    zürich, switzerland
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: nested countif

    thanks you guys are great

+ 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